Add “transpiled JavaScript” template - #161
Conversation
…not the one on GitHub.
…rather than introduce a new boolean flag.
|
Bump! Pinging @Daeraxa in case they'd like to do an informal review (but feel no obligation). |
confused-Techie
left a comment
There was a problem hiding this comment.
The code here overall looks super solid.
I'd like to test personally, but with the tests you've written (and checking for specific files like a rollup) I feel like we can be pretty confident in this one functioning.
Although it seems like to no fault of your own the Windows tests broke. Seems like we can't find our version of Visual Studio code, so we might wanna add a fix for that here, which I'm assuming can match a manual install of an older version in the workflow file, like I'm pretty sure we do in Pulsar.
Otherwise I left a comment on one file that still seemed to assume we require the transpile flag for this new template, which it sounds like you're trying to do away with.
…and point to `windows-2022` rather than `windows-latest`.
|
Also just pushed a workflow file update pinning to |
Daeraxa
left a comment
There was a problem hiding this comment.
Tried it out and it does what it says just fine. I've made some comments, some might be just nothing but at least a couple I think might need looking at.
There was a problem hiding this comment.
With all of my feedback addressed, as well as @Daeraxa's feedback, and with her actually trying the command directly, I think that should cover just about everything and we should be good to go!
EDIT::
Also thanks for fixing the CI here, I know it's entirely unrelated to your PR, but glad we could get it in somewhere we were already actively reviewing
This PR will be very similar to #152. I probably should've done both at once.
A Pulsar user writing a package for the first time in the year 2025 will discover that some of the dependencies they might want to use are ESM-only. Over time, this will become an even more common method of distribution. This is a problem for Pulsar because the renderer process is CJS-only, at least if you want to be able to use dependencies from the Node universe. This is a rigid requirement and Electron is unlikely to be able to change it in the near future.
This won't affect some kinds of packages. And, indeed, if you want to solve the ESM-only problem without transpiling your code, you can probably find an older version of the same dependency that had a CJS bundle, or find another package that does a similar thing and can serve up CJS. (Core packages can use these tactics to stave off transpilation for now.)
But it's better if users don't have to care about this! Hence this PR adds a new package template that sets them up with something that will automatically transpile ESM dependencies to CJS, where possible. (It's possible unless the ESM module uses bleeding-edge features like top-level
await, but this is pretty rare.)The TypeScript template in #152 already had this toolchain. This is the same thing, but for people who prefer to write in JavaScript.
This template therefore omits the TypeScript dependencies from
package.json… but it keeps the@types/atomdependency (the one that points to our own@pulsar-edit/typespackage) because those types are handy to have even for JS-only projects if the user haspulsar-ide-typescriptinstalled. (Also, now that our types package is published to NPM, I've updated thepackage.jsontemplates for both transpiled-JS and TypeScript to reference the NPM version of the library.)Testing
Specs are updated. But for manual testing, you can run something like
to generate a JS package and opt into the “transpiled” syntax. (I decided to add
javascript-transpiledas another valid option for--syntaxrather than introduce a one-off flag that has meaning only when other specific options are present.) Once you've generated the package,cdinto the new directory, runppm link --dev .to create a symlink in to~/.pulsar/dev/packages, then runpulsar --dev .to open a new dev-mode window for the package.You should be able to invoke (name of your package): Toggle in the command palette and trigger the “you must transpile this package first!” notification. You should also be able to run
npm installand thennpm run buildfrom the terminal, then reload your Pulsar window… and now (name of your package): Toggle should do the standard thing (create a new panel and put some silly text in it).