Babel Config Improvements for Webpack
Closed this issue · 0 comments
birdofpreyru commented
For @babel/preset-env
, here:
we want to add
modules: 'umd'
modules: 'amd'
for the front-end / option; and override it with modules: 'cjs',
in the node-ssr
babel config (https://github.com/birdofpreyru/react-utils/blob/master/config-ts-src/babel/node-ssr.ts).
In the production Webpack config for apps (https://github.com/birdofpreyru/react-utils/blob/master/config-ts-src/webpack/app-production.ts), we want to override babel-loader
settings (see current ones in the base config:
react-utils/config-ts-src/webpack/app-base.ts
Lines 323 to 335 in 936e3f7
- We want to remove
exclude
option, to ensure that ALL JS/TS, including that from_node_modules_
code passes through Babel when packing production app code. This is necessary to support older browsers, even when 3rd party libraries compiled for newer ones! - We also want to update the rule test (perhaps in base config file) to be
test: ops.typescript ? /\.((c?j|t)sx?|svg)$/ : /\.(c?jsx?|svg)$/,
to also transform.cjs
files, which might be used by 3rd party packages for CommonJS modules.