-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
80fc4ab
commit a14a3a3
Showing
41 changed files
with
1,769 additions
and
1,159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/lib | ||
/module.mjs | ||
/dts | ||
/esm | ||
/cjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,6 @@ yarn.lock | |
.vscode | ||
|
||
# Build files | ||
/lib | ||
/dts | ||
/esm | ||
/cjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
18.12.0 | ||
18.18.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
/package-lock.json | ||
/lib | ||
/dts | ||
/esm | ||
/cjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
'use strict'; | ||
|
||
const {name, version, engines} = require('./package.json'); | ||
|
||
const node = engines.node | ||
.split(/[^\d.]+/) | ||
.filter(s => s.length) | ||
.map(s => [...s.split('.').map(s => +s || 0), 0, 0].slice(0, 3)) | ||
.sort((a, b) => a[2] - b[2]) | ||
.sort((a, b) => a[1] - b[1]) | ||
.sort((a, b) => a[0] - b[0])[0] | ||
.join('.'); | ||
|
||
module.exports = api => { | ||
const env = api.env(); | ||
api.cache(() => env); | ||
const modules = env === 'esm' ? false : 'commonjs'; | ||
const ext = modules ? '.js' : '.mjs'; | ||
const presets = []; | ||
const plugins = []; | ||
presets.push([ | ||
'@babel/preset-env', | ||
{ | ||
modules, | ||
exclude: ['proposal-dynamic-import'], | ||
targets: { | ||
node | ||
} | ||
} | ||
]); | ||
presets.push(['@babel/preset-typescript']); | ||
if (modules === 'commonjs') { | ||
plugins.push([ | ||
'@babel/plugin-transform-modules-commonjs', | ||
{ | ||
importInterop: 'node' | ||
} | ||
]); | ||
} | ||
plugins.push([ | ||
'esm-resolver', | ||
{ | ||
source: { | ||
extensions: [ | ||
[['.js', '.mjs', '.jsx', '.mjsx', '.ts', '.tsx'], ext] | ||
] | ||
} | ||
} | ||
]); | ||
plugins.push([ | ||
'search-and-replace', | ||
{ | ||
rules: [ | ||
{ | ||
search: '#{NAME}', | ||
replace: name | ||
}, | ||
{ | ||
search: '#{VERSION}', | ||
replace: version | ||
} | ||
] | ||
} | ||
]); | ||
return { | ||
presets, | ||
plugins | ||
}; | ||
}; |
Oops, something went wrong.