-
-
Notifications
You must be signed in to change notification settings - Fork 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
Convert everything to ESM #349
Comments
I need to investigate how that affects the language server and vs code extension. Currently they only support cjs style. Related issue sveltejs/language-tools#509 |
@dummdidumm how confident are you that it's possible? should it be considered a blocker? |
Not sure at this moment. There were some ideas on how to accomplish it but ultimately I gotta test that out. I hope to get to this in the next few days. |
I have hit multiple walls and I am not confident that this can be resolved at this point. The current Electron (which powers VS Code) is at Node 12.x, so no native ESM support. This means we need to transpile the language-server code with What's left (that I know of) is import { register } from 'ts-node';
// inside a custom cosmiconfig loader function:
const loader = (filePath: string) => {
// ...
register({
transpileOnly: true,
compilerOptions: { module: 'CommonJS', esModuleInterop: true, allowJs: true },
skipProject: true
});
// ... The problem is that once
One alternative to circumvent all this is to say "dear Svelte Kit users, if you want your |
Instead of making a .cjs copy of the config file, what if the config file was always .cjs, until this issue is resolved? Would that bypass this mess? |
You mean instead of |
The interop is fine — you can |
I think this is done at this point with the exception of #400. Feel free to reopen if I'm wrong though |
Electron 12 uses Node v14 I believe (https://www.electronjs.org/releases/stable). Help > About shows VS Code is on Electron 11.3. Hopefully at some point it will be updated which my unblock language tools being able to use ESM |
It says it's currently on Node 12.18.3, is that not compatible with ESM? |
If I remember correctly, only with the |
According to the Node 12.17 changelog:
In fact, this is why our There seems to be an open issue about this: electron/electron#21457, in particular this interesting comment:
It's the exact same situation as the AWS lambdas! We only need the entry point to be CJS, and it can |
Interesting, will do a spike if I have the time testing this. If it works I need to come up with a good solution for the async loading of the config though, right now it's expected to be synchronous because that code path needs to be synchronous,too. |
I've burnt too many hours trying to resolve this issue.... I'm using typeorm and having issues running a migration, I keep getting the following error: `import type { MigrationInterface, QueryRunner } from "typeorm"; SyntaxError: Cannot use import statement outside a module` outside of compiling the ts to js and using the js file, I can't get this to work. I just want an out of the box experience without having to tweak the generated files. Am I doing something wrong? Is there something else that I need to do in order to get this to work? I assumed using the ts version when generating the project would give me all the settings that I need to run ts code. I put all my ts code inside the src/lib to avoid issues. I apologize if this is not the right place to ask, I tried on discord but was not able to get an answer. i have everything else working with typeorm except the migrations which uses their cli and causes this error. |
TypeOrm is known to have difficulties working with SvelteKit. See #798. Though there is a suggestion there of a Vite plugin to try using. No one has reported yet whether it works or not |
@benmccann I know what the issue is but I don't know how to resolve it without breaking sveltekit, maybe you can guide me. If I remove Is there a way around this where I don't have to make these changes? |
@benmccann I'm sorry to bother you, maybe this helps... I modified the recommendation in the typeorm documentation for adding the custom script by forcing it to use commonjs like so: The only issue now is getting around the Thank you in advance! |
This is a hack, please advise if you have a better solution:
Rewrite the type each time we run an npm script |
Modules are now fully supported in Node, except in Node 10 which will fall out of LTS very soon (the current 'active' LTS version is 14).
It makes sense, I think, for SvelteKit to fully embrace ESM, by which I mean that the CLI should be distributed as ESM, and that
svelte.config.js
andsnowpack.config.js
should be ESM.There is a practical benefit to this, aside from making everything new and shiny and futureproof: it means that you can trivially share modules between the app you're building and e.g.
npm run
scripts. (We've encountered this at the NYT — we have adecompress
module that is primarily used in the client to calculate things like rolling averages, which don't need to come over the wire, but which are also needed script-side to generate some summary data files.)The text was updated successfully, but these errors were encountered: