Skip to content

Commit

Permalink
fix(build): transpile source code properly against target envs (#3132)
Browse files Browse the repository at this point in the history
  • Loading branch information
char0n authored Sep 8, 2023
1 parent 88abf0d commit e633b0d
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 282 deletions.
19 changes: 19 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
[isomorphic-production]
> 1%
last 2 versions
Firefox ESR
not dead
node 12.20.0

[isomorphic-development]
last 1 Chrome versions
last 1 FireFox versions
last 1 Safari versions
node 20

[browser-production]
> 1%
last 2 versions
Firefox ESR
not dead

[browser-development]
last 1 Chrome versions
last 1 FireFox versions
last 1 Safari versions
65 changes: 26 additions & 39 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,100 +1,87 @@
/**
* This is override for https://github.com/lodash/babel-plugin-lodash/issues/259.
* babel-plugin-lodash is using deprecated babel API, which causes generation of many
* console.trace calls.
*/

const consoleTrace = console.trace.bind(console);
console.trace = (message, ...optionalParams) => {
if (
typeof message === 'string' &&
message.startsWith('`isModuleDeclaration` has been deprecated')
) {
return undefined; // noop
}

return consoleTrace(message, ...optionalParams);
};

module.exports = {
env: {
commonjs: {
browserslistEnv: 'isomorphic-production',
presets: [
[
'@babel/preset-env',
{
debug: false,
modules: 'commonjs',
corejs: { version: 3 },
loose: true,
useBuiltIns: false,
targets: {
node: '12.20.0',
},
forceAllTransforms: false,
ignoreBrowserslistConfig: true,
ignoreBrowserslistConfig: false,
},
],
],
plugins: [
[
'@babel/plugin-transform-modules-commonjs',
'@babel/plugin-transform-runtime',
{
loose: true,
corejs: { version: 3, proposals: false },
absoluteRuntime: false,
helpers: true,
regenerator: false,
version: '^7.22.15',
},
],
'@babel/proposal-class-properties',
'@babel/proposal-object-rest-spread',
],
},
es: {
browserslistEnv: 'isomorphic-production',
presets: [
[
'@babel/preset-env',
{
debug: false,
modules: false,
corejs: { version: 3 },
useBuiltIns: false,
forceAllTransforms: false,
ignoreBrowserslistConfig: false,
},
],
],
plugins: [
[
'@babel/plugin-transform-runtime',
{
corejs: { version: 3, proposals: false },
absoluteRuntime: false,
corejs: 3,
version: '^7.11.2',
helpers: true,
regenerator: false,
useESModules: true,
version: '^7.22.15',
},
],
'@babel/proposal-class-properties',
'@babel/proposal-object-rest-spread',
'lodash',
],
},
browser: {
browserslistEnv: 'browser-production',
sourceType: 'unambiguous', // https://github.com/webpack/webpack/issues/4039#issuecomment-419284940
presets: [
[
'@babel/preset-env',
{
debug: false,
corejs: { version: 3 },
modules: 'auto',
useBuiltIns: false,
forceAllTransforms: false,
ignoreBrowserslistConfig: false,
},
],
],
plugins: [
[
'@babel/plugin-transform-runtime',
{
corejs: 3,
version: '^7.11.2',
corejs: { version: 3, proposals: false },
absoluteRuntime: false,
helpers: true,
regenerator: false,
version: '^7.22.15',
},
],
'@babel/proposal-class-properties',
'@babel/proposal-object-rest-spread',
'lodash',
],
},
},
Expand Down
178 changes: 1 addition & 177 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e633b0d

Please sign in to comment.