Skip to content

Add “transpiled JavaScript” template - #161

Merged
savetheclocktower merged 9 commits into
masterfrom
add-javascript-transpiled-template
Jun 23, 2026
Merged

Add “transpiled JavaScript” template#161
savetheclocktower merged 9 commits into
masterfrom
add-javascript-transpiled-template

Conversation

@savetheclocktower

@savetheclocktower savetheclocktower commented Nov 23, 2025

Copy link
Copy Markdown
Contributor

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/atom dependency (the one that points to our own @pulsar-edit/types package) because those types are handy to have even for JS-only projects if the user has pulsar-ide-typescript installed. (Also, now that our types package is published to NPM, I've updated the package.json templates 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

bin/npm init --package some-package --syntax javascript-transpiled

to generate a JS package and opt into the “transpiled” syntax. (I decided to add javascript-transpiled as another valid option for --syntax rather than introduce a one-off flag that has meaning only when other specific options are present.) Once you've generated the package, cd into the new directory, run ppm link --dev . to create a symlink in to ~/.pulsar/dev/packages, then run pulsar --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 install and then npm run build from 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).

@savetheclocktower

Copy link
Copy Markdown
Contributor Author

Bump! Pinging @Daeraxa in case they'd like to do an informal review (but feel no obligation).

@confused-Techie confused-Techie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/init.js
…and point to `windows-2022` rather than `windows-latest`.
@savetheclocktower

Copy link
Copy Markdown
Contributor Author

Also just pushed a workflow file update pinning to windows-2022 (as we've done elsewhere) and shifting the matrix forward to include Node 20. (We certainly don't need to be testing 14 and 16 anymore, and even 18 is probably unnecessary.)

@savetheclocktower savetheclocktower changed the title Add javascript transpiled template Add “transpiled JavaScript” template Jun 20, 2026

@Daeraxa Daeraxa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread templates/package-javascript-transpiled/spec/__package-name__-spec.js.template Outdated
Comment thread templates/package-javascript-transpiled/styles/__package-name__.less.template Outdated
Comment thread src/init.js Outdated
Comment thread templates/package-javascript-transpiled/package.json Outdated
Comment thread templates/package-javascript-transpiled/lib/index.cjs Outdated

@confused-Techie confused-Techie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@savetheclocktower
savetheclocktower merged commit f3f412d into master Jun 23, 2026
8 checks passed
@savetheclocktower
savetheclocktower deleted the add-javascript-transpiled-template branch June 23, 2026 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants