From 9d5ab4bb4cfdf1f44fb61e5a68749aa55531421a Mon Sep 17 00:00:00 2001 From: "zc.zhang" Date: Fri, 12 May 2023 12:54:41 +0800 Subject: [PATCH] feat: remove require helper for commonjs --- .changeset/popular-carrots-tap.md | 5 +++++ packages/dev/config/babel-config-cjs.cjs | 4 ++-- packages/dev/config/babel-config-esm.cjs | 4 ++-- packages/dev/config/babel-config-webpack.cjs | 4 ++-- packages/dev/config/babel-plugins.cjs | 5 ++--- packages/dev/config/babel-presets.cjs | 4 +--- 6 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 .changeset/popular-carrots-tap.md diff --git a/.changeset/popular-carrots-tap.md b/.changeset/popular-carrots-tap.md new file mode 100644 index 0000000..526b9e8 --- /dev/null +++ b/.changeset/popular-carrots-tap.md @@ -0,0 +1,5 @@ +--- +"@zcloak/dev": minor +--- + +remove require helper for commonjs diff --git a/packages/dev/config/babel-config-cjs.cjs b/packages/dev/config/babel-config-cjs.cjs index 8f039ed..1c11a22 100644 --- a/packages/dev/config/babel-config-cjs.cjs +++ b/packages/dev/config/babel-config-cjs.cjs @@ -7,6 +7,6 @@ const presets = require('./babel-presets.cjs'); module.exports = { ...general, - plugins: plugins(false, false, false), - presets: presets(false, false) + plugins: plugins(false, false), + presets: presets(false) }; diff --git a/packages/dev/config/babel-config-esm.cjs b/packages/dev/config/babel-config-esm.cjs index cc160eb..3368869 100644 --- a/packages/dev/config/babel-config-esm.cjs +++ b/packages/dev/config/babel-config-esm.cjs @@ -7,6 +7,6 @@ const presets = require('./babel-presets.cjs'); module.exports = { ...general, - plugins: plugins(true, false, true), - presets: presets(true, false) + plugins: plugins(true, true), + presets: presets(true) }; diff --git a/packages/dev/config/babel-config-webpack.cjs b/packages/dev/config/babel-config-webpack.cjs index 057b551..e039300 100644 --- a/packages/dev/config/babel-config-webpack.cjs +++ b/packages/dev/config/babel-config-webpack.cjs @@ -7,6 +7,6 @@ const presets = require('./babel-presets.cjs'); module.exports = { ...general, - plugins: plugins(true, true, false), - presets: presets(true, true) + plugins: plugins(true, false), + presets: presets(true) }; diff --git a/packages/dev/config/babel-plugins.cjs b/packages/dev/config/babel-plugins.cjs index 9f36199..01cb311 100644 --- a/packages/dev/config/babel-plugins.cjs +++ b/packages/dev/config/babel-plugins.cjs @@ -3,7 +3,7 @@ const resolver = require('./babel-resolver.cjs'); -module.exports = function (isEsm, usage, doRewrite) { +module.exports = function (isEsm, doRewrite) { return resolver([ '@babel/plugin-proposal-nullish-coalescing-operator', '@babel/plugin-proposal-numeric-separator', @@ -11,8 +11,7 @@ module.exports = function (isEsm, usage, doRewrite) { [ '@babel/plugin-transform-runtime', { - corejs: usage ? 3 : false, - helpers: true, + helpers: false, regenerator: true, useESModules: isEsm } diff --git a/packages/dev/config/babel-presets.cjs b/packages/dev/config/babel-presets.cjs index 4d45b23..59132ef 100644 --- a/packages/dev/config/babel-presets.cjs +++ b/packages/dev/config/babel-presets.cjs @@ -3,7 +3,7 @@ const resolver = require('./babel-resolver.cjs'); -module.exports = function (isEsm, usage) { +module.exports = function (isEsm) { return resolver([ '@babel/preset-typescript', [ @@ -16,8 +16,6 @@ module.exports = function (isEsm, usage) { [ '@babel/preset-env', { - useBuiltIns: usage ? 'usage' : false, - corejs: usage ? 3 : false, exclude: [ // we don't want 2n ** 128n to Math.pow(2n, 128n) '@babel/plugin-transform-exponentiation-operator',