Skip to content

Conversation

@BitcoinErrorLog
Copy link
Owner

Summary

  • Build content script as IIFE format instead of ES modules using separate Vite config
  • Add chrome.storage availability check in logger to prevent errors in content scripts
  • Update package.json build script to run both Vite builds

Problem

Content scripts were failing with:

  1. "Cannot use import statement outside a module" - because content.js was built as ES module
  2. "Cannot read properties of undefined (reading 'local')" - because the shared logger tried to access chrome.storage in content script context

Solution

  • Created vite.content.config.ts to build content script as IIFE format
  • Added isStorageAvailable check in logger before accessing chrome.storage.local
  • Updated build script to run both builds sequentially

Test Plan

  • Extension builds successfully
  • Content script loads without errors
  • Annotation button appears on text selection
  • No chrome.storage errors in console

- Build content script as IIFE format (not ES modules) using separate vite config
- Add chrome.storage availability check in logger to prevent errors in content scripts
- Update package.json build script to run both vite builds
@BitcoinErrorLog BitcoinErrorLog merged commit f5cf779 into main Dec 10, 2025
1 of 3 checks passed
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 49 to 51
'profile-renderer': resolve(__dirname, 'src/profile/profile-renderer.html'),
offscreen: resolve(__dirname, 'src/offscreen/offscreen.html'),
background: resolve(__dirname, 'src/background/background.ts'),

Choose a reason for hiding this comment

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

P1 Badge Dev build no longer emits content script

The main Vite config now omits the content script from rollupOptions.input, but npm run dev (and any watch build using the default config) still relies solely on this file. Running the documented dev build now produces a dist without content.js, so the extension fails to load its content script when loaded in Chrome even though the manifest still references it.

Useful? React with 👍 / 👎.

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