-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Really fix issue with detecting AMD-like imports #4010
Conversation
#4009 fixed it for TypeScript, but the same detection can be performed on JavaScript.
We want/need it in JavaScript, as there are situations where we are transpiling from AMD to ESM using the compiler, as mentioned in the PR. |
Do such situations currently exist or is it pure theory? |
They exist. |
Please provide an example. |
The only time JavaScript source files are created in the compiler is when define(["./foo.ts"], function (foo) {
console.log(foo);
}); would emit as something like: import * as foo from "./foo.ts";
console.log(foo); The same applies for CommonJS modules: const foo = require("./foo.ts");
console.log(foo); I know this because I wrote the code, so it isn't speculation on my part. It is an intentional feature. The reason why there is an option in the TypeScript preprocess is specifically for this transpilation feature as well. |
Could you provide more specific steps? I ran your CommonJS example in a directory with the following tsconfig.json: {
"compilerOptions": {
"checkJs": true,
"allowJs": true
}
} It didn't seem to be converted to ESM:
|
You need to pass the tsconfig.json as an argument to Deno. It does not automatically detect it. |
Do you get a different result? |
The issue is still there if tsconfig.json {
"compilerOptions": {
"checkJs": true,
"allowJs": true
}
} foo.ts import "./test.js"; test.js function define(foo) {}
define(["long"]); ..\deno\target\debug\deno.exe --config tsconfig.json foo.ts
|
I've opened #4110 with your report. Let's move the discussion there. |
#4009 fixed it for TypeScript, but the same detection can be performed on JavaScript.