question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stop transpiling `import` to `require`

See original GitHub issue

Unlike 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:closed
  • Created 6 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
hedgepigdanielcommented, Jan 22, 2018

Adding module.strictExportPresence: true to the default webpack config would also generate errors when importing non existent exports. Saves a huge amount of time.

1reaction
hedgepigdanielcommented, Jan 22, 2018

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 like babel-preset-env etc. That way you can just add that option to the react-native preset options in .babelrc.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found