Skip to content

chore: migrate to bun (phase 1) - #247

Open
nicomiguelino wants to merge 2 commits into
masterfrom
chore/migrate-to-bun/phase-1
Open

chore: migrate to bun (phase 1)#247
nicomiguelino wants to merge 2 commits into
masterfrom
chore/migrate-to-bun/phase-1

Conversation

@nicomiguelino

Copy link
Copy Markdown
Collaborator

Summary

  • Switch Docker image, CI workflows, and dev scripts from npm to bun.
  • Replace package-lock.json with bun.lock.
  • Fix jsdom opaque origin error and scss mock loading under Bun's module resolver.

This is phase 1 of a multi phase migration. Later phases will be stacked on top.

Test plan

  • docker compose build succeeds
  • bunx webpack --config webpack.prod.js produces a valid dist/ (manifest.json, popup.bundle.js, popup.html)
  • bun run test passes all 29 specs
  • bun run lint:check and bun run format:check pass on src/

Switch Docker image, CI workflows, and dev scripts from npm to bun.
Fix jsdom opaque origin error and scss mock loading under Bun's
module resolver.
Copilot AI lite review requested due to automatic review settings August 24, 2026 03:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Phase 1 of migrating the project’s dev/build/test toolchain from npm/node base images to Bun, updating Docker + CI execution paths and adjusting the test environment to behave correctly under Bun (notably JSDOM origin handling and CSS/SCSS import mocking).

Changes:

  • Switch container base image and container-invoked commands from npm/npx to bun/bunx (Dockerfile, workflows, and helper scripts).
  • Add JSDOM url configuration to avoid “opaque origin” issues (enables localStorage/sessionStorage access in tests).
  • Replace Node-only CSS/SCSS require hooks with a Bun-aware plugin, while preserving Node compatibility.

Reviewed changes

Copilot reviewed 7 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/test/environment.js Sets a concrete JSDOM URL to prevent opaque-origin failures in the test environment.
spec/helpers/mock-styles.js Adds a Bun plugin to mock .css/.scss loads under Bun, with a Node fallback using require.extensions.
spec/helpers/jsdom.js Updates JSDOM initialization to include a URL for consistent origin behavior.
Dockerfile Migrates the build image from node:22 to oven/bun:1.4.0 and installs deps via bun install using bun.lock.
docker-compose.yml Runs the dev webpack watcher via bunx instead of npx.
bin/run_tests.sh Runs tests via bun run test inside the container.
bin/run_formatter.sh Runs formatting via bun run format:* inside the container.
bin/run_eslint.sh Runs lint checks via bun run lint:check inside the container.
bin/package_extension.sh Builds the production bundle via bunx webpack inside the container.
.github/workflows/test.yaml Updates CI test job to use bunx + bun run test in the container.
.github/workflows/build.yaml Updates CI build job to use bun run build in the container.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

FlatCompat.extends('plugin:@typescript-eslint/recommended') loads a
legacy eslintrc config via import-fresh, which calls
module.parent.require, a Node internal Bun's module loader does not
implement. Use typescript-eslint's native flat config export instead.
Also format eslint.config.mjs, which sits outside the format:check
src/ scope and had never been run through Prettier.
Copilot AI review requested due to automatic review settings August 24, 2026 03:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 14 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

Dockerfile:10

  • bun install in the Docker build is not using a frozen/locked mode. That means a Docker/CI build can silently resolve different dependency versions than what bun.lock specifies (or even rewrite the lockfile), reducing reproducibility. Consider using bun install --frozen-lockfile for image builds.
ADD package.json /app/package.json
ADD bun.lock /app/bun.lock
RUN bun install

Comment on lines 49 to 53
-v $(pwd)/artifacts:/app/artifacts:delegated \
-v /app/artifacts/node_modules \
screenly-browser-extension:latest \
/bin/bash -c "npm run build && cp -r dist/ artifacts/"
/bin/bash -c "bun run build && cp -r dist/ artifacts/"

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