-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for .cjs .mjs and .js with package.json type="module" (#4873
) Summary: When using Node.js projects with `"type": "module"` in package.json, the relay compiler currently fails to load configuration files due to incompatibilities between ESM and CommonJS See #4060 (comment) This pr handle all three module format scenarios: - Native ES modules (.mjs) - CommonJS modules (.cjs) - Regular .js files that respect the package.json "type" field It works by switching from Node `require()` to dynamic `import()` and using the `--input-type=module` flag I also added a new test and verified that this approach works for Node 18.0.0 fixes #4060 Pull Request resolved: #4873 Reviewed By: lynnshaoyu Differential Revision: D68588063 Pulled By: captbaritone fbshipit-source-id: 992583b86d993c6e31c6b57f1e8ea8af07dbf4cc
- Loading branch information
1 parent
6165081
commit 08e45d7
Showing
5 changed files
with
30 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters