Skip to content

Fix JS scaffold build + add CLI template smoke test#58

Merged
jodeleeuw merged 2 commits into
mainfrom
fix-js-template-babel-deps
Jun 16, 2026
Merged

Fix JS scaffold build + add CLI template smoke test#58
jodeleeuw merged 2 commits into
mainfrom
fix-js-template-babel-deps

Conversation

@jodeleeuw

Copy link
Copy Markdown
Member

Summary

A user hit babel: command not found running npm run build on a freshly scaffolded new-plugin JS package. Root cause was a broken JavaScript template, and validating the fix surfaced a second build bug — so this PR fixes both across all three generators and adds CI to keep it from regressing.

Template fixes (all three JS templates)

  • Missing Babel toolchain: the build script invokes babel with @babel/preset-env + the minify preset, but none of @babel/cli, @babel/core, @babel/preset-env, babel-preset-minify were in devDependencies. After a clean npm install the babel binary didn't exist → "babel not found". Pinned to the Babel 7 line, which is compatible with the (2022-era) babel-preset-minify.
  • Wrong source path: build compiled index.js at the package root, but the source ships at src/index.js (like the TS templates) → babel: index.js does not exist. Fixed the path and updated files to publish src instead of the non-existent index.js.

Affects @jspsych/new-plugin, @jspsych/new-extension, @jspsych/new-timeline (patch changeset included). TS templates were already fine.

New CI: CLI Template Smoke Test

End-to-end workflow that, for a 3×2 matrix (each CLI × ts/js), scaffolds a package non-interactively, then runs npm install + npm run build in the generated package and asserts dist/index.browser.min.js is produced. This is what caught the second bug. Runs on PRs touching the CLI packages, pushes to main, and manual dispatch.

Testing

Ran the full scaffold → install → build flow locally for all six combinations — all pass:

new-plugin     ts/js -> plugin-smoke-test      OK
new-extension  ts/js -> extension-smoke-test   OK
new-timeline   ts/js -> smoke-test             OK

Note (out of scope)

package-lock.json is out of sync — npm ci fails on missing @esbuild/* platform optional deps (pre-existing, also affects release.yml). Happy to regenerate the lockfile in a follow-up.

🤖 Generated with Claude Code

jodeleeuw and others added 2 commits June 16, 2026 11:49
The JavaScript scaffolding templates' build script invoked `babel` with
presets that were never declared as devDependencies, so `npm run build`
failed with "babel not found" after a fresh install. The build also
compiled a non-existent `index.js` at the package root instead of the
actual source at `src/index.js`.

- Add @babel/cli, @babel/core, @babel/preset-env, babel-preset-minify
  (Babel 7 line, compatible with the babel-preset-minify minifier).
- Point `build` at src/index.js and publish `src` in `files`, matching
  the TypeScript templates.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
End-to-end CI that scaffolds a package with each generator
(new-plugin/new-extension/new-timeline x ts/js) and verifies it installs
and builds from a clean checkout, asserting dist/index.browser.min.js is
produced. Catches broken template package.json scripts/dependencies
before they reach the published CLIs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jun 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b4fcb5b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@jspsych/new-plugin Patch
@jspsych/new-extension Patch
@jspsych/new-timeline Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jodeleeuw jodeleeuw merged commit 03468e5 into main Jun 16, 2026
6 checks passed
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.

1 participant