-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add babel and create cjs build (#324)
- Loading branch information
1 parent
b98fb70
commit a38d860
Showing
10 changed files
with
2,069 additions
and
406 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
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,12 @@ | ||
// Copyright 2017-2023 @polkadot/dev authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
const general = require('./babel-general.cjs'); | ||
const plugins = require('./babel-plugins.cjs'); | ||
const presets = require('./babel-presets.cjs'); | ||
|
||
module.exports = { | ||
...general, | ||
plugins: plugins(false), | ||
presets: presets(false) | ||
}; |
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,15 @@ | ||
// Copyright 2017-2023 @polkadot/dev authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
module.exports = { | ||
assumptions: { | ||
// ensure that ?. & ?? uses !=/== null checks (not also undefined) | ||
noDocumentAll: true, | ||
// no extra defineProperty for private class fields | ||
privateFieldsAsProperties: true, | ||
// no extra defineProperty for public class fields | ||
setPublicClassFields: true | ||
} | ||
// Really want to switch this on, but not as of yet... | ||
// comments: false | ||
}; |
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,21 @@ | ||
// Copyright 2017-2023 @polkadot/dev authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
const resolver = require('./babel-resolver.cjs'); | ||
|
||
module.exports = function (isEsm) { | ||
return resolver([ | ||
'@babel/plugin-proposal-nullish-coalescing-operator', | ||
'@babel/plugin-proposal-numeric-separator', | ||
'@babel/plugin-proposal-optional-chaining', | ||
['@babel/plugin-transform-runtime', { | ||
useESModules: isEsm | ||
}], | ||
'@babel/plugin-syntax-bigint', | ||
'@babel/plugin-syntax-dynamic-import', | ||
'@babel/plugin-syntax-import-assertions', | ||
'@babel/plugin-syntax-import-meta', | ||
'@babel/plugin-syntax-top-level-await', | ||
'babel-plugin-styled-components' | ||
]); | ||
}; |
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,33 @@ | ||
// Copyright 2017-2023 @polkadot/dev authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
const resolver = require('./babel-resolver.cjs'); | ||
|
||
module.exports = function (isEsm) { | ||
return resolver([ | ||
'@babel/preset-typescript', | ||
['@babel/preset-react', { | ||
development: false, | ||
runtime: 'automatic' | ||
}], | ||
['@babel/preset-env', { | ||
exclude: [ | ||
// we don't want 2n ** 128n to Math.pow(2n, 128n) | ||
'@babel/plugin-transform-exponentiation-operator', | ||
// we don't want await import(...) to Promise.resolve(require(...)) | ||
'proposal-dynamic-import' | ||
], | ||
modules: isEsm | ||
? false | ||
: 'commonjs', | ||
targets: isEsm | ||
? { | ||
node: '14' | ||
} | ||
: { | ||
browsers: '>0.25% and last 2 versions and not ie 11 and not OperaMini all', | ||
node: '14' | ||
} | ||
}] | ||
]); | ||
}; |
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,14 @@ | ||
// Copyright 2017-2023 @polkadot/dev authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
module.exports = function resolver (input) { | ||
return Array.isArray(input) | ||
? input | ||
.filter((plugin) => !!plugin) | ||
.map((plugin) => | ||
Array.isArray(plugin) | ||
? [require.resolve(plugin[0]), plugin[1]] | ||
: require.resolve(plugin) | ||
) | ||
: require.resolve(input); | ||
}; |
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
Oops, something went wrong.