Migrate code to ESM modules#683
Merged
Merged
Conversation
Replace global-based scripts with ES modules: split the codebase into focused modules (constants, converter, dom, fetch, page, settings, theme), add a dynamic-import bootstrap content script, and update vendor files and manifest accordingly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add an HTTP server (tasks/server.js) for ESM imports to work over http:// instead of file://. Load modules dynamically in beforeEach via page.evaluate() and expose them as window globals. Update test-page.html to load vendor scripts as classic scripts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
f67a8b0 to
914cf0b
Compare
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace dynamic import() with static ESM import in contentScript.js (dynamic import never resolved in Firefox due to transitive imports) - Remove Firefox-specific local fetch+convert code from main.js; both browsers now send fetch-convert to the background script - Fix isExtensionEnabled() to return true by default on fresh install Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add esbuild to bundle contentScript.js into an IIFE (content-bundle.js) so it loads as a classic script without requiring "type: module", which would break vendor scripts in the same content_scripts entry - Both Chrome and Firefox now use content-bundle.js - Add scripting permission for scripting.insertCSS API - Add downloadFonts() build step: downloads Google Fonts woff2 files locally and generates app/css/asciidoctor-fonts.css - Add fonts/asciidoctor/* to web_accessible_resources Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace <link> element injection with sendMessage({ action: 'insert-css' })
calls to the background; scripting.insertCSS() is not subject to page CSP
- Background resolves @import rules by fetching and inlining them,
and rewrites all relative url() references to absolute extension URLs
before injecting, fixing broken font paths on sandboxed pages
- Fix Firefox Promise rejection when no content script listener exists
- Fix enable/disable state inversion in background script
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace the Google Fonts @import in asciidoctor.css with a reference to a locally generated asciidoctor-fonts.css containing @font-face rules pointing to bundled woff2 files. Fonts load entirely from the extension, with no external network requests, and work even on pages with strict CSP. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…igin scripting.insertCSS with css: gives the stylesheet a null principal in Firefox, which blocks loading moz-extension:// font URLs even when listed in web_accessible_resources. Using files: mode gives the stylesheet the extension's own origin, which allows @font-face rules to load font files directly from moz-extension://. Chrome keeps the inline css: approach (rewritten absolute URLs) because its files: mode incorrectly resolves url() relative to the page, not the file. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace global-based scripts with ES modules: split the codebase into
focused modules (constants, converter, dom, fetch, page, settings, theme),
add a dynamic-import bootstrap content script, and update vendor files
and manifest accordingly.
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com