Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File writer refactor #427

Merged
merged 143 commits into from
Oct 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
c68e0bf
refactor: rename files and functions
jacksteamdev Oct 9, 2022
ff5218c
feat: add file writer draft
jacksteamdev Oct 9, 2022
92c2b16
feat: add new file writer
jacksteamdev Oct 9, 2022
3cff07f
fix: allow for absolute outDir
jacksteamdev Oct 9, 2022
d0a9086
fix: remove leading slash for scripts in manifest
jacksteamdev Oct 9, 2022
9c78b5c
feat: re-integrate content script plugin
jacksteamdev Oct 9, 2022
c8ffedb
feat: remove previous work
jacksteamdev Oct 9, 2022
01c67b1
draft file writer
jacksteamdev Oct 9, 2022
ccd834e
refactor: move rxmap to own file
jacksteamdev Oct 9, 2022
6296aec
feat: add plugins to serve rollup config
jacksteamdev Oct 9, 2022
378829c
refactor: rename stubMatchPattern
jacksteamdev Oct 9, 2022
46124d2
chore: tweak eslint
jacksteamdev Oct 9, 2022
b1c9f4b
refactor: move type to interface
jacksteamdev Oct 9, 2022
02c2ffd
feat: draft web acc res
jacksteamdev Oct 9, 2022
6b1b45d
feat: draft rest of file writer
jacksteamdev Oct 9, 2022
da831c2
feat: add fileWriter polyfill
jacksteamdev Oct 9, 2022
1ae3a73
feat: implement script resources compiler
jacksteamdev Oct 9, 2022
19e92f3
fix: support <dynamic_script> and <all_urls>
jacksteamdev Oct 9, 2022
666ddb0
fix: adjust plugin order
jacksteamdev Oct 9, 2022
4840d07
fix: emit module type dynamic scripts
jacksteamdev Oct 9, 2022
86cb10e
fix: replace dynamic module scripts in output
jacksteamdev Oct 9, 2022
cab7c07
tests: remove comment
jacksteamdev Oct 9, 2022
9e81e62
fix: add dynamic script web accessible resources
jacksteamdev Oct 9, 2022
01e7a78
fix: respect injectCss option
jacksteamdev Oct 9, 2022
72c2780
fix: combine redundant web acc res
jacksteamdev Oct 9, 2022
90b9b27
fix: prefer to compile resources from rollup bundle
jacksteamdev Oct 9, 2022
a4c79fc
fix: remove dynamic resource placeholder
jacksteamdev Oct 9, 2022
bf6fd1b
tests: update build output tests
jacksteamdev Oct 9, 2022
b83f164
fix: copy then splice
jacksteamdev Oct 9, 2022
a998627
tests: update snapshot
jacksteamdev Oct 9, 2022
081e25b
refactor: simplify content script map
jacksteamdev Oct 9, 2022
03b6aa6
tests: assert hashScriptId returns a stable hash
jacksteamdev Oct 9, 2022
6422606
fix: ensure stable scriptId during build
jacksteamdev Oct 9, 2022
fa3a773
fix: resolve webcomponents polyfill
jacksteamdev Oct 9, 2022
a0c2f29
fix: allow for use during serve
jacksteamdev Oct 9, 2022
ac31f73
fix: start file writer after server is listening
jacksteamdev Oct 9, 2022
556ff53
fix: configure rollup
jacksteamdev Oct 9, 2022
e6f842c
fix: save file in filewriter
jacksteamdev Oct 9, 2022
68766ca
refactor: adjust output filenames
jacksteamdev Oct 9, 2022
af06ea1
fix: add precontroller html files
jacksteamdev Oct 9, 2022
f0dc77c
fix: lexer to get correct module deps
jacksteamdev Oct 9, 2022
341e6a3
fix: handle vite urls with @fs
jacksteamdev Oct 9, 2022
6652373
tests: update snapshot
jacksteamdev Oct 9, 2022
36a5e53
fix: update import names
jacksteamdev Oct 9, 2022
78b3329
fix: reduce scope of filename transformation
jacksteamdev Oct 9, 2022
491b221
fix: remove leading slash in filenames, adjust
jacksteamdev Oct 9, 2022
27e650c
fix: output imported assets
jacksteamdev Oct 9, 2022
22a9771
fix: support `?url` import queries
jacksteamdev Oct 9, 2022
f14fa46
fix: handle optimized deps
jacksteamdev Oct 9, 2022
9a4dd55
add html placeholder only in serve
jacksteamdev Oct 9, 2022
823c815
fix: look up content script by file name
jacksteamdev Oct 9, 2022
5266b6a
fix: use absolute path for script src
jacksteamdev Oct 9, 2022
5d51310
fix: remove extra html files from serve input
jacksteamdev Oct 9, 2022
233f502
tests: update snapshots
jacksteamdev Oct 9, 2022
cc6282a
refactor: remove unnecesary async function
jacksteamdev Oct 9, 2022
29bf31c
fix: wait for rollup build to complete
jacksteamdev Oct 9, 2022
6dc706a
feat: output public files in serve mode
jacksteamdev Oct 9, 2022
5787c9b
refactor: expand with brackets
jacksteamdev Oct 9, 2022
fc5f1e1
fix: stop file write when server closes
jacksteamdev Oct 9, 2022
8cde4a8
fix: emit file and loader name in serve mode
jacksteamdev Oct 9, 2022
47ba45f
tests: remove console log
jacksteamdev Oct 9, 2022
e9d5207
tests: update snapshots
jacksteamdev Oct 9, 2022
e407143
fix: exclude html files from serve
jacksteamdev Oct 9, 2022
fe891ba
tests: add more granulated test scripts
jacksteamdev Oct 9, 2022
572e614
tests: replace use of google.com with example.com
jacksteamdev Oct 9, 2022
c126792
feat: add hmr plugin
jacksteamdev Oct 9, 2022
0f221a1
tests: remove uses of google.com
jacksteamdev Oct 9, 2022
6178b01
tests: one more google
jacksteamdev Oct 9, 2022
8a0f1c5
tests: update snapshots
jacksteamdev Oct 9, 2022
651aef4
tests: add example route to e2e build
jacksteamdev Oct 9, 2022
3dddab2
fix: strip @id prefix from id modules
jacksteamdev Oct 9, 2022
3e05364
tests: wait for optimized deps to finish
jacksteamdev Oct 9, 2022
19dd0ad
feat: add hmr payloads
jacksteamdev Oct 9, 2022
79d582f
wip - hmr updates
jacksteamdev Oct 9, 2022
fa2b659
tests: update build snapshots
jacksteamdev Oct 9, 2022
d0b5f40
tests: retry e2e tests on fail
jacksteamdev Oct 9, 2022
26b6cb0
tests: add new named image snapshots
jacksteamdev Oct 9, 2022
4cd659a
tests: adjust timing
jacksteamdev Oct 9, 2022
22d84eb
refactor: move observable to rxjs file
jacksteamdev Oct 9, 2022
1b10541
feat: migrate to options provider
jacksteamdev Oct 9, 2022
fe851cc
tests: split hmr out into own test stage
jacksteamdev Oct 9, 2022
37f3f63
tests: remove hash in test output
jacksteamdev Oct 9, 2022
1516e93
tests: migrate to options provider
jacksteamdev Oct 9, 2022
0e38ae1
tests: scrub test output
jacksteamdev Oct 9, 2022
33f6650
fix: ignore type error
jacksteamdev Oct 9, 2022
47aaa23
tests: fix client file generation
jacksteamdev Oct 9, 2022
3cbb657
tests: add vitest
jacksteamdev Oct 9, 2022
929f5c7
wip - setup vitest
jacksteamdev Oct 9, 2022
f7d085e
fix: use absolute paths for build entry points
jacksteamdev Oct 9, 2022
f30fb70
gitignore workspace config file
jacksteamdev Oct 9, 2022
7056583
restore snapshot
jacksteamdev Oct 9, 2022
6aa7bf7
tests: fix fast-glob stalling
jacksteamdev Oct 9, 2022
ea450eb
tests: fix import path errors
jacksteamdev Oct 9, 2022
fdffa7e
fix: search root not cwd for files
jacksteamdev Oct 9, 2022
e345bf0
chore: format files
jacksteamdev Oct 9, 2022
44362bf
test: adjust snapshots
jacksteamdev Oct 9, 2022
d8c68d2
tests: fail tests on build errors
jacksteamdev Oct 9, 2022
6f680fd
tests: ignore error when closing server
jacksteamdev Oct 9, 2022
82a4844
chore: configure eslint
jacksteamdev Oct 9, 2022
dd7ccbf
tests: don't wait for optimized deps
jacksteamdev Oct 9, 2022
faa78c8
test: wait for optimizedDeps to complete
jacksteamdev Oct 9, 2022
8ede366
chore: add formatting script
jacksteamdev Oct 9, 2022
c7b2091
tests: improve error output
jacksteamdev Oct 9, 2022
a69536f
test: attempt to stabilize file hashes
jacksteamdev Oct 9, 2022
cc7a6ff
chore: add jest-image-snapshot
jacksteamdev Oct 9, 2022
8ffdaea
tests: enable e2e tests with image snapshots
jacksteamdev Oct 9, 2022
3637032
tests: surface file writer errors
jacksteamdev Oct 9, 2022
3c3cbc4
tests: add null byte to file writer url
jacksteamdev Oct 9, 2022
6fb9f64
tests: fix test
jacksteamdev Oct 9, 2022
ae50bd3
tests: add e2e and ci test scripts
jacksteamdev Oct 9, 2022
8c3c207
chore: fix lockfile
jacksteamdev Oct 9, 2022
8be5c53
fix: ignore linting error
jacksteamdev Oct 9, 2022
6c22df4
tests: reconfigure github actions
jacksteamdev Oct 9, 2022
4bb9336
ci: upgrade node version
jacksteamdev Oct 9, 2022
9b520f7
tests: fix scriptId
jacksteamdev Oct 9, 2022
f77c8fb
tests: fix test output normalization
jacksteamdev Oct 9, 2022
d9d520c
chore: add support for running single tests
jacksteamdev Oct 9, 2022
c6d2dee
tests: rename image snapshots
jacksteamdev Oct 9, 2022
84cdb5c
tests: add retries to e2e tests in CI
jacksteamdev Oct 9, 2022
fdbfa1c
ci: add delay after test
jacksteamdev Oct 9, 2022
439cc90
ci: add console logs
jacksteamdev Oct 9, 2022
eba9791
ci: add console.logs
jacksteamdev Oct 9, 2022
29a3c4d
ci: add timeouts
jacksteamdev Oct 9, 2022
17540ee
ci: fix config
jacksteamdev Oct 9, 2022
c52274f
ci: add more detailed logs
jacksteamdev Oct 9, 2022
a699fc8
chore: switch rpce to playwright-chromium
jacksteamdev Oct 9, 2022
9569e0b
ci: change order of event listeners
jacksteamdev Oct 9, 2022
5a80445
add log to filewriter hmr
jacksteamdev Oct 9, 2022
082aee0
ci: upgrade pnpm
jacksteamdev Oct 9, 2022
cf5abb2
chore: add console log to pnpmfile
jacksteamdev Oct 9, 2022
3fd3def
chore: add npm-run-all to vite plugin
jacksteamdev Oct 9, 2022
0be56a8
ci: try load event vs framenavigated
jacksteamdev Oct 9, 2022
05b04d6
ci: enable debug
jacksteamdev Oct 9, 2022
c75e331
ci: more debugging
jacksteamdev Oct 9, 2022
98c4a40
tests+ci: track route requests instead of page loads
jacksteamdev Oct 9, 2022
46b7b80
tests: refactor for ci
jacksteamdev Oct 9, 2022
ce2c3e8
tests: fix timing
jacksteamdev Oct 9, 2022
c4bbf42
Revert "tests: fix timing"
jacksteamdev Oct 9, 2022
cddad11
Revert "tests: refactor for ci"
jacksteamdev Oct 9, 2022
d2271af
tests: try to fix flaky test
jacksteamdev Oct 9, 2022
aa9453d
ci: add dev dep
jacksteamdev Oct 9, 2022
259fecf
tests+ci: skip flaky test in CI
jacksteamdev Oct 9, 2022
630c073
docs: add comment on flaky test
jacksteamdev Oct 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 15 additions & 28 deletions .github/workflows/vite-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ defaults:
jobs:
# Runs linter and unit tests
checks:
name: Lint and Unit Tests
name: Lint

# The type of runner that the job will run on
runs-on: ubuntu-latest
Expand All @@ -37,15 +37,15 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: "14"
node-version: "16"

- name: Setup PNPM
# You may pin to the exact commit or the version.
# uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
uses: pnpm/action-setup@v2.2.2
with:
# Version of PNPM to install
version: 6.3.0
version: 7.9.5
# Where to store PNPM files
# dest: # optional, default is ~/setup-pnpm
# If specified, run `pnpm install`
Expand All @@ -64,42 +64,34 @@ jobs:
restore-keys: ${{ runner.os }}-${{ env.cache-name }}-

- name: Install dependencies
run: pnpm install
run: pnpm install --filter "vite-plugin"

- name: Lint files
run: pnpm lint

- name: Unit tests
run: pnpm test:units

# Runs e2e tests in Playwright
e2e:
name: E2E Tests

# The type of runner that the job will run on
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
type: [build, serve]

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: "14"
node-version: "16"

- name: Setup PNPM
# You may pin to the exact commit or the version.
# uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
uses: pnpm/action-setup@v2.2.2
with:
# Version of PNPM to install
version: 6.3.0
version: 7.9.5
# Where to store PNPM files
# dest: # optional, default is ~/setup-pnpm
# If specified, run `pnpm install`
Expand All @@ -120,10 +112,10 @@ jobs:
- name: Install dependencies
run: pnpm i

- name: Run ${{ matrix.type }} tests
- name: Run e2e tests
uses: GabrielBB/xvfb-action@v1
with:
run: pnpm test:ci:e2e:${{ matrix.type }}
run: pnpm test:ci:e2e
working-directory: "packages/vite-plugin"

- uses: actions/upload-artifact@v3
Expand All @@ -132,34 +124,29 @@ jobs:
name: image-diff-${{ matrix.type }}
path: ${{ github.workspace }}/tests/**/__image_snapshots__/__diff_output__/*.png

# Runs output snapshot tests
output:
name: Output Snapshot Tests
# Runs unit and output tests
unit:
name: Unit and Output Tests

# The type of runner that the job will run on
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
type: [build, serve]

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: "14"
node-version: "16"

- name: Setup PNPM
# You may pin to the exact commit or the version.
# uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
uses: pnpm/action-setup@v2.2.2
with:
# Version of PNPM to install
version: 6.3.0
version: 7.9.5
# Where to store PNPM files
# dest: # optional, default is ~/setup-pnpm
# If specified, run `pnpm install`
Expand All @@ -180,8 +167,8 @@ jobs:
- name: Install dependencies
run: pnpm i

- name: Run ${{ matrix.type }} tests
run: pnpm test:ci:mv3:${{ matrix.type }}
- name: Run unit and output tests
run: pnpm test:ci:unit

- name: Check for diff
id: diff
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ TODOs.md
*.local
packages/vite/LICENSE
types
**/.docusaurus
**/.docusaurus
crxjs.code-workspace
11 changes: 11 additions & 0 deletions .pnpmfile.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
hooks: {
readPackages(pkg) {
if (pkg.name === 'jest-image-snapshot') {
delete pkg.peerDependencies.jest
console.log('fixing jest-image-snapshot peer deps')
}
return pkg
},
},
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@
},
"engines": {
"node": ">=14"
},
"devDependencies": {
"vitest": "^0.23.4"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { remove } from 'fs-extra'
import { chromium, ChromiumBrowserContext, Page } from 'playwright'
import { chromium, ChromiumBrowserContext, Page } from 'playwright-chromium'
import { InputOptions, OutputOptions, rollup } from 'rollup'
import { getExtPath, getTestName, requireExtFile } from '../__fixtures__/utils'

Expand Down
2 changes: 1 addition & 1 deletion packages/rollup-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"localforage": "^1.9.0",
"lodash": "^4.17.21",
"mem": "^6.0.1",
"playwright-chromium": "1.21.1",
"rollup": "^2.72.1",
"slash": "^3.0.0",
"webextension-polyfill": "^0.9.0"
Expand Down Expand Up @@ -94,7 +95,6 @@
"jest-html-reporters": "3.0.8",
"jest-in-case": "^1.0.2",
"npm-run-all": "^4.1.5",
"playwright": "^1.13.1",
"prettier": "^2.3.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand Down
3 changes: 2 additions & 1 deletion packages/vite-plugin/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = {
vars: 'all',
args: 'after-used',
ignoreRestSiblings: true,
varsIgnorePattern: 'self',
varsIgnorePattern: 'self|debug',
},
],
'prefer-const': [
Expand All @@ -45,5 +45,6 @@ module.exports = {
// note you must disable the base rule as it can report incorrect errors
'no-extra-semi': 'off',
'@typescript-eslint/no-extra-semi': 'off',
'no-empty': ['error', { allowEmptyCatch: true }],
},
}
2 changes: 1 addition & 1 deletion packages/vite-plugin/modules.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="vite/client" />

declare module '*?client' {
declare module 'client/*' {
const code: string
export default code
}
Expand Down
40 changes: 18 additions & 22 deletions packages/vite-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"client.d.ts"
],
"scripts": {
"format": "prettier -w -c ../../.prettierrc.yaml",
"build": "run-s build:clean build:js",
"build:clean": "rimraf dist",
"build:js": "rollup -c rollup.config.ts --configPlugin esbuild",
Expand All @@ -50,15 +51,11 @@
"lint": "run-s lint:eslint lint:types",
"lint:eslint": "eslint \"{src,test}/**/*.ts\"",
"lint:types": "tsc --noEmit",
"test": "run-s test:units test:update:*",
"test:ci:e2e:build": "node --expose-gc ./node_modules/jest/bin/jest.js --logHeapUsage --runInBand --forceExit --testPathIgnorePatterns=\\(/node_modules/ /templates/ /mv3/\\) -t build",
"test:ci:e2e:serve": "npm run test:ci:e2e:serve:cmd || npm run test:ci:e2e:serve:cmd",
"test:ci:e2e:serve:cmd": "node --expose-gc ./node_modules/jest/bin/jest.js --logHeapUsage --runInBand --forceExit --testPathIgnorePatterns=\\(/node_modules/ /templates/ /mv3/\\) -t serve",
"test:ci:mv3:build": "node --expose-gc ./node_modules/jest/bin/jest.js --logHeapUsage --runInBand --forceExit --testPathIgnorePatterns=\\(/node_modules/ /templates/ /e2e/\\) --updateSnapshot build",
"test:ci:mv3:serve": "node --expose-gc ./node_modules/jest/bin/jest.js --logHeapUsage --runInBand --forceExit --testPathIgnorePatterns=\\(/node_modules/ /templates/ /e2e/\\) --updateSnapshot serve",
"test:units": "jest src",
"test:update:build": "jest build -u",
"test:update:serve": "jest serve -u"
"test": "vitest --mode unit",
"test:e2e": "vitest --mode e2e",
"test:ci": "run-s test:ci:*",
"test:ci:unit": "vitest --run --mode unit",
"test:ci:e2e": "vitest --run --mode e2e"
},
"dependencies": {
"@rollup/pluginutils": "^4.1.2",
Expand All @@ -74,7 +71,7 @@
"magic-string": "^0.26.0",
"picocolors": "^1.0.0",
"react-refresh": "^0.13.0",
"rollup": "^2.70.2"
"rollup": "2.78.1"
},
"devDependencies": {
"@extend-chrome/messages": "1.2.2",
Expand All @@ -86,21 +83,22 @@
"@types/chrome": "0.0.190",
"@types/debug": "4.1.7",
"@types/fs-extra": "9.0.13",
"@types/jest": "27.5.2",
"@types/jest-image-snapshot": "4.3.1",
"@types/jest-image-snapshot": "^5.1.0",
"@types/jsesc": "3.0.1",
"@types/node": "17.0.18",
"@types/react": "17.0.44",
"@types/react-dom": "17.0.17",
"@typescript-eslint/eslint-plugin": "5.27.1",
"@typescript-eslint/parser": "5.27.1",
"@vitejs/plugin-react": "1.3.2",
"@vitejs/plugin-vue": "2.3.3",
"@vitejs/plugin-react": "^2.1.0",
"@vitejs/plugin-vue": "3.1.0",
"chokidar": "^3.5.3",
"esbuild": "0.14.43",
"esbuild-runner": "2.2.1",
"eslint": "8.17.0",
"jest": "27.5.1",
"jest-image-snapshot": "5.1.0",
"eslint-plugin-react": "^7.29.4",
"jest-image-snapshot": "^5.2.0",
"npm-run-all": "^4.1.5",
"playwright-chromium": "1.21.1",
"react": "17.0.2",
"react-dom": "17.0.2",
Expand All @@ -109,15 +107,13 @@
"rollup-plugin-esbuild": "4.9.1",
"rxjs": "7.5.5",
"typescript": "^4.6.4",
"vite": "^2.9.5",
"vite-plugin-inspect": "0.5.0",
"vite": "^3.1.3",
"vite-plugin-inspect": "0.7.2",
"vitest": "^0.23.4",
"vue": "3.2.36"
},
"peerDependencies": {
"vite": "^2.9.0"
},
"optionalDependencies": {
"@vitejs/plugin-react": ">=1.2.0"
"vite": "^2.9.0 <= ^3.1.3"
},
"engines": {
"node": ">=14"
Expand Down
19 changes: 7 additions & 12 deletions packages/vite-plugin/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,26 @@ const bundleClientCode = (): Plugin => {
return null
},
resolveId(source, importer) {
if (importer && source.includes('?client')) return source
if (importer && source.endsWith('?client')) return source
},
async load(id) {
if (id.includes('?client')) {
const url = new URL(id, 'stub://stub')
const filepath = url.pathname
const format = path.dirname(filepath).split('/').pop() as
if (id.endsWith('?client')) {
const format = path.dirname(id).split('/').pop() as
| 'es'
| 'iife'
| 'html'
const input = id.split('?')[0]

let result: string
if (format === 'html') {
result = await fs.readFile(filepath, { encoding: 'utf8' })
result = await fs.readFile(input, { encoding: 'utf8' })
} else {
const build = await rollup({
...options,
input: filepath,
})

const build = await rollup({ ...options, input })
const { output } = await build.generate({ format })
result = output[0].code
}

this.addWatchFile(filepath)
this.addWatchFile(id)

return `export default "${jsesc(result, { quotes: 'double' })}"`
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vite-plugin/src/client/es/hmr-client-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
declare const self: ServiceWorkerGlobalScope
export {}

import { CrxHMRPayload } from 'src/types'
import type { CrxHMRPayload } from 'src/types'
import type { HMRPayload } from 'vite'

// injected by the hmr plugin when served
Expand Down
2 changes: 1 addition & 1 deletion packages/vite-plugin/src/client/html/precontroller.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<title>Waiting for the extension service worker...</title>
<script src="%PATH%"></script>
<script src="%SCRIPT%"></script>
</head>
<body>
<h1>Waiting for service worker</h1>
Expand Down
Loading