Stop transpiling `import` to `require`
See original GitHub issueUnlike packager, webpack has now native support for import and leaving it that way will not only simplify HMR setup but also enable possible code optimisations.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
How to prevent typescript from transpiling dynamic imports ...
By doing this, dynamic import would not be transpiled into require() , and you can use dynamic import to import a CommonJS or...
Read more >Add flag to not transpile dynamic `import()` when module is ...
Yet I'm not able to tell the TS compiler to not transpile this into Promise.resolve().then(() => __importStar(require('..'))); . This prevents ...
Read more >How to Correctly Use TypeScript Module Import Syntax and ...
JavaScript with CommonJS can use “require()” to import other CommonJS modules, but can only use dynamic import “import()” to import ES Modules.
Read more >TSConfig Option: esModuleInterop - TypeScript
the ES6 modules spec states that a namespace import ( import * as x ) can only be an object, by having TypeScript...
Read more >babel/plugin-transform-modules-commonjs
This plugin transforms ECMAScript modules to CommonJS. Note that only the syntax of import/export statements ( import "./mod.js" ) and import expressions ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Adding
module.strictExportPresence: trueto the default webpack config would also generate errors when importing non existent exports. Saves a huge amount of time.I made a PR to react-native here to allow that. Not sure when/if they will merge it or reimplement it, but in the meantime, Perhaps haul could use this: https://github.com/hedgepigdaniel/babel-preset-react-native?
Its just a fork of babel-preset-react-native which adds a
"modules"option much likebabel-preset-envetc. That way you can just add that option to the react-native preset options in.babelrc.