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

Fix invalid use of ES modules #2073

Merged
merged 1 commit into from
Nov 3, 2020
Merged

Conversation

ef4
Copy link
Contributor

@ef4 ef4 commented Nov 3, 2020

The ES module spec doesn't support "optional" exports. If you try to import a name from a module and that name is not exported, it's a SyntaxError.

Mirage tries to import default, testConfig, and makeServer from the user's config, but they are treated as optional.

The solution is to import the module's whole namespace (import * as...) and then inspect the namespace object.

The ES module spec doesn't support "optional" exports. If you try import a name from a module and that name is not exported, it's a SyntaxError.

Mirage tries to import `default`, `testConfig`, and `makeServer` from the user's config, but they are treated as optional.

The solution is to import the module's whole namespace (`import * as...`) and then inspect the namespace object.
@ef4
Copy link
Contributor Author

ef4 commented Nov 3, 2020

(I'm adding an audit tool to Embroider, and any app that uses ember-cli-mirage will see a problem in their audit results due to this issue.)

@samselikoff samselikoff merged commit ba5ef27 into miragejs:master Nov 3, 2020
@samselikoff
Copy link
Collaborator

Makes sense - thanks for the PR Ed!

@ef4 ef4 deleted the optional-exports branch November 3, 2020 14:27
@Turbo87 Turbo87 added the Bug label Dec 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants