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

Recognize .mjs as JavaScript files #792

Merged
merged 1 commit into from
Dec 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/analyzer/src/core/analysis-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export class AnalysisContext {
readonly parsers = new Map<string, Parser<ParsedDocument>>([
['html', new HtmlParser()],
['js', new JavaScriptParser()],
['mjs', new JavaScriptParser()],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course, you could create a single const jsParser = new JavaScriptParser(); and then use the the same instance for both js and mjs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can also skip all the import/export scanning for .mjs files.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, we want to add more contextual inference for treating a file as a script vs module, and .mjs would be a strong signal.

No objection to landing this as is though.

['css', new CssParser()],
['json', new JsonParser()],
]);
Expand Down