Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CJS -> ESM transpiler #73

Open
matthewp opened this issue Apr 26, 2017 · 1 comment
Open

Add CJS -> ESM transpiler #73

matthewp opened this issue Apr 26, 2017 · 1 comment

Comments

@matthewp
Copy link
Member

matthewp commented Apr 26, 2017

Add a transpile that will transpile CommonJS to ESM format.

"use strict";

var foo = require("foo");

module.exports = foo;

becomes:

import foo from "foo";

export default foo;
@matthewp
Copy link
Member Author

matthewp commented Apr 26, 2017

By default this should only work with strict mode modules. Those that have "use strict"; at the top of the file. If transpile encounters any module that's not strict mode it should throw as it is impossible to guarantee the module will work once converted to ES format.

To work around this, allow an { unsafe: true } option that ignores whether strict mode is there or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant