mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-14 03:43:23 +00:00
[fix] CommonJS exports can be imported without 'default'
Make sure all the CommonJS modules can be required as normal, rather than needing to be suffixed with `.default` due to being compiled from ES modules.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
module.exports = {
|
||||
const createConfig = ({ modules }) => ({
|
||||
presets: [
|
||||
[
|
||||
'babel-preset-env',
|
||||
{
|
||||
loose: true,
|
||||
modules: process.env.MODULES || false,
|
||||
modules,
|
||||
exclude: ['transform-es2015-typeof-symbol'],
|
||||
targets: {
|
||||
browsers: [
|
||||
@@ -31,5 +31,10 @@ module.exports = {
|
||||
['babel-plugin-transform-class-properties', { loose: true }],
|
||||
['babel-plugin-transform-object-rest-spread', { useBuiltIns: true }],
|
||||
['babel-plugin-transform-react-remove-prop-types', { mode: 'wrap' }]
|
||||
]
|
||||
};
|
||||
].concat(modules ? ['babel-plugin-add-module-exports'] : [])
|
||||
});
|
||||
|
||||
module.exports =
|
||||
process.env.BABEL_ENV === 'commonjs'
|
||||
? createConfig({ modules: 'commonjs' })
|
||||
: createConfig({ modules: false });
|
||||
|
||||
Reference in New Issue
Block a user