-
Notifications
You must be signed in to change notification settings - Fork 2
Upgrading to latest Svelte version, 3.42.1 #5
Comments
You can compile the compiler.js file bundled with acorn, css-tree, and the others if you set |
I haven't tested it but it looks like it's complaining about the Unless the compiler for the newer versions changed a lot, commenting out the first self that obtains the global scope variable and replacing the second NoteI believe that graalvm announced some time ago that there's now experimental, but official support for NodeJS with all the C++ bindings. Here's the reference: https://www.graalvm.org/reference-manual/js/ I won't close the issue yet, I'll try look into it when I get the time. |
Commenting out those 'self' references did the trick! I am getting an error in the browser
Interesting stuff about the NodeJS support, do you think it would be better to implement the compiling of svelte components this way? |
In the future maybe not, depending on wether or not the GraalVM team will allow interoperability from Java directly to NodeJS. At this moment, yes. I just tested it and it works perfectly out of the box with the latest version of Svelte. When I'm done I'll archive this repo and redirect you to the new project. |
I put together a simple project using the mechanism I explained above: https://github.com/tncrazvan/svelte3jssr There's no magic happening with the "import" keyword this time, it's using modern javascript and it also is not using a modified svelte compiler, it's using the original one inside node_modules, so the newest versions should work just fine. I've included a few recommendations for VScode plugins: Those are the official recommended plugins from the GraalVM team and I also included the Lombok plugin so that Lombok beans would work (they don't work in VSCode by default). You should get a popup in VSCode to install them when u open the editor. After you've installed graalvm you need to install the NodeJS plugin for Graal. Just execute Run There's no development watcher yet, but you can disable this flag So that the server recompiles the component everytime. |
I am interested in leveraging this in one of my projects and as part of learning how this works I wanted to try to update to the latest Svelte version.
I cloned the Svelte repo and built a new compiler.js file.
I then had to include some extra npm dependencies
Now, I am a little stuck as this code returns an error when executing this code
It complains that "ReferenceError: self is not defined", which I believe means that the compile function can not be called in this way anymore. I would think it should be accessible as I can see
exports.compile = compile;
in the new compiler.js I created. I'm looking more into this now to see if i can find a solution but if anyone has an idea let me know!The text was updated successfully, but these errors were encountered: