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.

Add support for ES6 import syntax

See original GitHub issue

This might be a long shot but I’d like to see this in browserify.

The ES6 module syntax has a few nice features compared to commonJS require method, namely bindings and cyclic dependencies.

Since these things are in the ES6 standard it seems reasonable to work them into browserify too!

Note that just using a ES6 to ES5 transpiler wouldn’t work in this case because these are cross module concerns. For instance, babelify is only able to transpile import foo from 'foo' to var foo = require('foo') at file-level, but this does not allow cyclic dependencies.

The Esperanto project has a nice way of handling things but lacks too many features to be a valid replacement for browserify.

Is there any possibility to see support for ES6 import syntax come to browserify?

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:57
  • Comments:59 (22 by maintainers)

github_iconTop GitHub Comments

23reactions
mattdeslcommented, Jul 10, 2018

For the mean time, I’ve created a browserify plugin that:

  • Adds .mjs extension to browserify so that it takes precedence over .js
  • Use "module" field in package.json (when "browser" is not specified)
  • Transform ES Module import/export syntax into CommonJS so that it can be consumed & used by browserify

See here: https://github.com/mattdesl/esmify

10reactions
ghostcommented, Apr 1, 2015

I’ve been waiting for this feature to land in node first so browserify can match the semantics properly. I’m also concerned that if browserify implements a default es6 import mechanism while node doesn’t have one, it will needlessly fragment browser and server ecosystems.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use an ES6 import in Node.js? - GeeksforGeeks
Introduction to ES6 import: The import statement is used to import modules that are exported by some other module. A module is a...
Read more >
ES6 Modules and How to Use Import and Export in JavaScript
The ES2015 (ES6) edition of the JavaScript standard gives us native support for modules with the import and export syntax.
Read more >
import - JavaScript - MDN Web Docs - Mozilla
The static import declaration is used to import read-only live bindings which are exported by another module. The imported bindings are ...
Read more >
How to use ES6 import syntax in Node.js - DEV Community ‍ ‍
How to use ES6 import syntax in Node.js ... A module is a JavaScript file that exports one or more values. The exported...
Read more >
How to use ES6 import syntax in Node.js - Aman Mittal
How to use ES6 import syntax in Node.js ... A module is a JavaScript file that exports one or more values. The exported...
Read more >

github_iconTop Related Medium Post

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 Hashnode Post

No results found