Skip to content

Use es modules#58

Merged
eumalin merged 1 commit into
mainfrom
holdings-checker-es-modules
Jun 12, 2026
Merged

Use es modules#58
eumalin merged 1 commit into
mainfrom
holdings-checker-es-modules

Conversation

@eumalin

@eumalin eumalin commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

I saw that the main js file was growing too big. It made more sense to split it into es modules with help from AI.

Split print-holdings-checker.js into three modules under src/js/print-holdings-checker/: validate.js has the type definitions and validation logic, ui.js has the card and error rendering, and index.js is the entry point that wires everything together.

In local dev WordPress serves the raw index.js as a native ES module, so I added a type="module" case to the existing add_type_attribute filter in functions.php (local env only). For deploy, esbuild now bundles the modules into the same dist/js/print-holdings-checker.min.js it always produced

The old print-holdings-checker.js is gone, and watch_build.js and package.json both point to the new entry point with --bundle added.

@carylwyatt

Copy link
Copy Markdown
Member

This looks good! Thanks for the explanation, it made it easy for me to know exactly what I was looking at.

@eumalin eumalin marked this pull request as ready for review June 12, 2026 18:02
@eumalin eumalin merged commit f87ccae into main Jun 12, 2026
@eumalin eumalin deleted the holdings-checker-es-modules branch June 12, 2026 18:42
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.

2 participants