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

feat: introduce API parity between JS and WASM implementation #27

Merged
merged 1 commit into from
Nov 1, 2020

Conversation

SimenB
Copy link
Member

@SimenB SimenB commented Nov 1, 2020

As discussed in #15.

@@ -19,7 +19,9 @@ npm install cjs-module-lexer
For use in CommonJS:

```js
const parse = require('cjs-module-lexer');
const { parse, init } = require('cjs-module-lexer');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if we should require it to be called or not. E.g. what happens if I use import('cjs-module-lexer')? Possibly confusing. Dunno 🙂

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we're changing the API regardless it might be worth it. happy to make the change if you want 👍

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strictly speaking, the way the exports are defined in https://github.com/guybedford/cjs-module-lexer/blob/master/package.json#L6, import() should always get the ES module form by definition of the resolution rules and even in bundlers (which RollupJS and Webpack support now!)

This was referenced Nov 1, 2020
Comment on lines +1326 to +1327
module.exports.init = () => initPromise;
module.exports.parse = parseCJS;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this could be done without breaking changes:

module.exports = (source, name) => parseCJS(source, name);
module.exports.init = () => initPromise;
module.exports.parse = parseCJS;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. @guybedford thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it simple as a major change actually. Saves on type differences / leaving deprecation for subsequent work.

@guybedford guybedford merged commit 0477548 into nodejs:master Nov 1, 2020
@SimenB SimenB deleted the same-api branch November 1, 2020 23:11
@SimenB
Copy link
Member Author

SimenB commented Nov 1, 2020

Doesn't seem like CI is set up for this repo - I didn't think to run the tests so I assume they are broken. Sorry about that @guybedford! I've put away the computer for the day, but I can probably send a PR fixing it tomorrow

@guybedford
Copy link
Collaborator

No problem, I added the test changes already.

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

Successfully merging this pull request may close these issues.

3 participants