-
-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revamp builds #800
Revamp builds #800
Changes from 8 commits
5b1468d
b6f96bf
196ff0b
2e2e47c
b616617
508c29f
ff9a211
7f22682
1c2f34c
ed211f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,50 +39,6 @@ var resolve_config = nodeResolve({ | |
}); | ||
|
||
|
||
// esm & cjs | ||
const inputs = [ | ||
'tom-select.ts', | ||
'tom-select.complete.ts', | ||
'tom-select.popular.ts', | ||
'utils.ts', | ||
]; | ||
|
||
inputs.forEach((slug)=>{ | ||
|
||
let input = path.resolve(__dirname,'../src',slug) | ||
|
||
// esm | ||
configs.push({ | ||
input: input, | ||
output:{ | ||
//file: path.resolve(__dirname,'../build/esm',slug), | ||
dir: path.resolve(__dirname,'../build/esm'), | ||
format: 'esm', | ||
preserveModules: false, | ||
sourcemap: true, | ||
banner: banner, | ||
}, | ||
plugins:[babel_config,resolve_config,], | ||
}); | ||
|
||
// cjs | ||
configs.push({ | ||
input: input, | ||
output:{ | ||
dir: path.resolve(__dirname,'../build/cjs'), | ||
format: 'cjs', | ||
preserveModules: false, | ||
sourcemap: true, | ||
banner: banner, | ||
exports: "auto", | ||
}, | ||
plugins:[babel_config,resolve_config], | ||
}); | ||
|
||
}); | ||
|
||
|
||
|
||
var terser_config = terser({ | ||
mangle: true, | ||
//toplevel: true, // removes tomSelect footer | ||
|
@@ -128,7 +84,7 @@ function configCore( input, filename, plugins ){ | |
|
||
var output = { | ||
name: 'TomSelect', | ||
file: `build/js/${filename}`, | ||
file: `dist/js/${filename}`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAICT the |
||
footer: 'var tomSelect=function(el,opts){return new TomSelect(el,opts);} ', | ||
}; | ||
|
||
|
@@ -156,15 +112,15 @@ var plugin_dir = path.resolve(__dirname,'../src/plugins'); | |
var files = fs.readdirSync( plugin_dir ); | ||
files.map(function(file){ | ||
let input = path.resolve(__dirname,'../src/plugins',file,'plugin.ts'); | ||
let output = {file:`build/js/plugins/${file}.js`,'name':file}; | ||
let output = {file:`dist/js/plugins/${file}.js`,'name':file}; | ||
pluginConfig( input, output); | ||
|
||
|
||
// esm | ||
configs.push({ | ||
input: input, | ||
output:{ | ||
file: path.resolve(__dirname,'../build/esm/plugins',file,'plugin.js'), | ||
file: path.resolve(__dirname,'../dist/esm/plugins',file,'plugin.js'), | ||
format: 'esm', | ||
preserveModules: false, | ||
sourcemap: true, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"module": "CommonJS", | ||
"moduleResolution": "Node", | ||
"outDir": "../dist/cjs" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"module": "NodeNext", | ||
"outDir": "../dist/esm" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
// This exists for backwards compatibility. In the wild, folks are importing | ||
// paths like `tom-select/dist/types/...`. | ||
// | ||
// Consider removing this in the next major version. | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../dist/types", | ||
"emitDeclarationOnly": true | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Node.js CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: ['18.x', '20.x', '22.x'] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm ci | ||
- run: npm run build | ||
- run: npm run test | ||
- run: npm run test:types | ||
- run: npm run stylelint |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
.DS_Store | ||
.vscode | ||
.DAV | ||
node_modules | ||
*.log | ||
*.tmp.* | ||
package-lock.json | ||
*.lock | ||
build/* | ||
build-docs/* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npm run test:typescript | ||
npm run build:types | ||
npm run stylelint |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,9 +49,9 @@ If you don't need any plugins, or want to load plugins individually, use <code>t | |
Add plugins to your project by including their js files and calling `TomSelect.define`. | ||
|
||
```js | ||
import TomSelect from 'tom-select/dist/js/tom-select.base.js'; | ||
import TomSelect_remove_button from 'tom-select/dist/js/plugins/remove_button.js'; | ||
import TomSelect_dropdown_header from 'tom-select/dist/js/plugins/dropdown_header.js'; | ||
import TomSelect from 'tom-select/base'; | ||
import TomSelect_remove_button from 'tom-select/plugins/remove_button.js'; | ||
import TomSelect_dropdown_header from 'tom-select/dropdown_header.js'; | ||
Comment on lines
+52
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO this is cleaner and transparently handles ESM vs. CJS. This is enabled by the new |
||
|
||
TomSelect.define('remove_button', TomSelect_remove_button); | ||
TomSelect.define('dropdown_header', TomSelect_dropdown_header); | ||
|
@@ -60,10 +60,10 @@ TomSelect.define('dropdown_header', TomSelect_dropdown_header); | |
Alternatively you can `require` plugins directly if your build tool supports it. | ||
|
||
```js | ||
import TomSelect from 'tom-select/dist/js/tom-select.base.js'; | ||
import TomSelect from 'tom-select/base'; | ||
|
||
TomSelect.define('remove_button', require('tom-select/dist/js/plugins/remove_button.js')); | ||
TomSelect.define('dropdown_header', require('tom-select/dist/js/plugins/dropdown_header.js')); | ||
TomSelect.define('remove_button', require('tom-select/plugins/remove_button.js')); | ||
TomSelect.define('dropdown_header', require('tom-select/plugins/dropdown_header.js')); | ||
``` | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These builds are now handled by
tsc
.