-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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(unstable): repurpose --unstable-detect-cjs
to attempt loading more modules as cjs
#27094
Conversation
…re modules as cjs
I actually much prefer using a package.json with type commonjs than this flag but that doesn't seem to work with relative import |
@@ -4373,7 +4374,7 @@ impl CommandExt for Command { | |||
).arg( | |||
Arg::new("unstable-detect-cjs") | |||
.long("unstable-detect-cjs") | |||
.help("Reads the package.json type field in a project to treat .js files as .cjs") | |||
.help("Treats ambiguous .js, .jsx, .ts, .tsx files as CommonJS modules in more cases") | |||
.value_parser(FalseyValueParser::new()) | |||
.action(ArgAction::SetTrue) | |||
.hide(true) |
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.
Unhide?
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.
I thought so too, but all of the unstable flags seem hidden
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.
Oh, just make sure it's shown when you do deno run --help=unstable
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
…more modules as cjs (#27094) This resurrects the `--unstable-detect-cjs` flag (which became stable), and repurposes it to attempt loading .js/.jsx/.ts/.tsx files as CJS in the following additional scenarios: 1. There is no package.json 1. There is a package.json without a "type" field Also cleans up the implementation of this in the LSP a lot by hanging `resolution_mode()` off `Document` (didn't think about doing that until now).
This resurrects the
--unstable-detect-cjs
flag (which became stable), and repurposes it to attempt loading .js/.jsx/.ts/.tsx files as CJS in the following additional scenarios:Also cleans up the implementation of this in the LSP a lot by hanging
resolution_mode()
offDocument
(didn't think about doing that until now).Related issues: