-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
modules that neither export nor import shouldn't be wrapped in define-call #4989
Comments
Input const hello = "world";
console.log(hello); define((function () { 'use strict';
const hello = "world";
console.log(hello);
})); |
I think we should follow behavior of TSC: https://www.typescriptlang.org/play?#code/HYQwtgpgzgDiDGEAEAzA9mpBvAUEpUakA5gDZoBGIpAdCsABQCUA3DgL5A |
You can use But How do you invoke swc? |
cannot agree more. |
@magic-akari Do you mean we should support it in |
Sure. We can follow Babel config. https://babeljs.io/docs/en/options#sourcetype FYI https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#control-over-module-detection |
@kdy1 Is https://swc.rs/docs/configuration/compilation#multiple-entries actually supported inside .swcrc? E.g declaring an array of configs in it I get errors complaining about invalid JSON |
Yes, but note that regex syntax is one of rust regex crate |
@jrieken Can you share your |
@kdy1 there you go. It looks like it failing as soon as I put the config-object into an array (e.g works when it's a top-level object) [
{
"test": "\\.ts$",
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": false,
"decorators": true
},
"target": "es2020",
"loose": false,
"minify": {
"compress": false,
"mangle": false
}
},
"module": {
"type": "amd",
"noInterop": true
},
"minify": false
}
] |
Funny... I see the error below running
|
@jrieken I.. don't think we support top level array as config unless if I miss something? Please allow me a dumb q, any specific reason you need to use array instead of an object for the swcrc config? |
@kwonoj We support top level array. |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Describe the bug
This is maybe controversial and something we can tackle on our end but it is different from how
tsc
behavesInput code
Config
Playground link
https://play.swc.rs/?version=1.2.203&code=H4sIAAAAAAAAA8tLzE0tLkhMTlVIy89XqOZSUCjOz01Nz8lPSszRS8vT0LTmqgUAxm2peCQAAAA%3D&config=H4sIAAAAAAAAA0WOTQ6DQAhG70JcNmpceoPewc1kxL84wwQw1RjvXqzR7sjj%2Bx7skIkfMDioYVBNdVFMQjG%2FoCgx5sR9IR%2FPHl6Aq5%2BXFi3dNPkkmaFJPNQ7JMeCfE6yRXWrRXRLKJ7HpBZTMdS5WfAFLXpiZ3KBWnnBw9aOe1QroVRlVVphJhJ8KmGMY7edek8hMYr8Vy728508zBWoXU6w%2Fz4wpwutCSO9oyJTeo7e0qv5BTnH4YgMAQAA
Expected behavior
With tsc the define-call is skipped because the code doesn't export or import anything.
https://www.typescriptlang.org/play?module=2#code/HYQwtgpgzgDiDGEAEAzA9mpBvAUEpUakA5gDZoBGIpAdCsABQCUA3DgL5A
Actual behavior
The code is wrapped in a define call making it hard ti transpile code that actually bootstraps the AMD logic
Version
1.2.203
Additional context
relates to, but not strictly needed for, microsoft/vscode#150025
The text was updated successfully, but these errors were encountered: