Skip to content

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

Merged
guybedford merged 1 commit into
nodejs:masterfrom
SimenB:same-api
Nov 1, 2020
Merged

feat: introduce API parity between JS and WASM implementation#27
guybedford merged 1 commit into
nodejs:masterfrom
SimenB:same-api

Conversation

@SimenB

@SimenB SimenB commented Nov 1, 2020

Copy link
Copy Markdown
Member

As discussed in #15.

Comment thread README.md

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 thread lexer.js
Comment on lines +1326 to +1327
module.exports.init = () => initPromise;
module.exports.parse = parseCJS;

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

SimenB commented Nov 1, 2020

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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