Skip to content

Load power-strip.js as ES module (import.meta.url path detection) (v0.4.5)#110

Merged
sergeychernyshev merged 2 commits into
mainfrom
feat/power-strip-module-script
Jul 1, 2026
Merged

Load power-strip.js as ES module (import.meta.url path detection) (v0.4.5)#110
sergeychernyshev merged 2 commits into
mainfrom
feat/power-strip-module-script

Conversation

@sergeychernyshev

Copy link
Copy Markdown
Member

Load power-strip.js as an ES module

Switches every power-strip.js injection to <script type="module" async> — the auto-injected tag (PowerStrip.ts), the internal pages (profile / accounts / admin), and the manual theme test.

Path detection

Module scripts execute with document.currentScript === null, so the previous detection (currentScript + a last-<script> fallback) breaks. Replaced with import.meta.url, the module's own URL — the reliable way for the script to locate itself and derive basePath.

Verified

  • Real-browser check (headless Chrome against wrangler dev): the custom element upgrades, basePath resolves to /users, and there are no console errors.
  • power-strip.js is module-safe: it uses addEventListener (no inline handlers), and its only global contract is customElements.define.
  • powerstrip.spec.ts assertions updated to the new tag; tsc + eslint clean; suite 129/129.

Bumps to 0.4.5.

🤖 Generated with Claude Code

sergeychernyshev and others added 2 commits June 30, 2026 22:46
Switch every power-strip.js injection to `<script type="module" async>`
(the auto-injected one in PowerStrip.ts, the three internal pages, and the
manual theme test).

Module scripts run with `document.currentScript === null`, so the old
path-detection (currentScript, with a last-<script> fallback) no longer
works. Replace it with `import.meta.url`, which is the module's own URL and
the reliable way to locate ourselves. Verified in a real browser that the
element still upgrades and basePath resolves to "/users" with no errors.

power-strip.js is safe as a module: it uses addEventListener (no inline
handlers) and its only global contract is customElements.define, which is
unaffected by module scoping.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 1, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
startup-api 5a62db4 Jul 01 2026, 02:47 AM

@sergeychernyshev sergeychernyshev merged commit fbe7b21 into main Jul 1, 2026
2 checks passed
@sergeychernyshev sergeychernyshev deleted the feat/power-strip-module-script branch July 1, 2026 02:48
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