-
Notifications
You must be signed in to change notification settings - Fork 75
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(compartment-mapper): CommonJS with lexical analysis #666
Conversation
d507e26
to
d1a7f35
Compare
Tests pass and working end to end. Will follow-up with more commits to increase test coverage and catch up with changes to the original lexer that have landed since the PR I forked from. |
@kriskowal , great to see this! But yes, please do break it up. Thanks. |
9069966
to
9d8cd1e
Compare
This change is now reduced to the last of three parts, a small adjustment to the compartment mapper that finishes the job. I choose you @michaelfig. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Just out of curiosity, is the case where MJS uses the CJS affordances handled?
Example, trivially:
import something from './other';
console.log(__dirname, something);
export const foo = require('soso');
That's a feature we use in some of our -resm
packages, though not as trivially.
The MJS module type does not support that particular misfeature since it’s not compatible with Node.js (creates an expectation that it ought to work though it won’t). This is very tricky. On the one hand, we could introduce a |
This change reintroduces support for CommonJS modules, but using a lexical analyzer instead of a full-parser analyzer. This reuses the analyzer built by @guybedford for Node.js, but including the import graph analysis by @developit in nodejs/cjs-module-lexer#10.
Fixes #501
Refs #655
The change consists of three parts.
Individual commits are reviewable. If requested, I can arrange for this change to be distributed into three or more smaller reviews. This is currently proposed as draft so review can begin while I increase the test coverage over over the lexer.