@crxjs/vite-plugin 1.0.9 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,74 +1,30 @@
1
- # [rollup-plugin-chrome-extension](https://www.extend-chrome.dev/rollup-plugin)
1
+ # ![CRXJS](./banner-github.png)
2
2
 
3
- [![npm (scoped)](https://img.shields.io/npm/v/rollup-plugin-chrome-extension/beta.svg)](https://www.npmjs.com/package/rollup-plugin-chrome-extension)
4
- [![GitHub last commit](https://img.shields.io/github/last-commit/crxjs/rollup-plugin-chrome-extension.svg?logo=github)](https://github.com/crxjs/rollup-plugin-chrome-extension)
5
- ![GitHub action badge](https://github.com/crxjs/rollup-plugin-chrome-extension/actions/workflows/vite-plugin.yml/badge.svg)
6
- [![TypeScript Declarations Included](https://img.shields.io/badge/types-TypeScript-informational)](#typescript)
3
+ [![npm (scoped)](https://img.shields.io/npm/v/rollup-plugin-chrome-extension.svg)](https://www.npmjs.com/package/rollup-plugin-chrome-extension)
4
+ [![GitHub last commit](https://img.shields.io/github/last-commit/crxjs/chrome-extension-tools.svg?logo=github)](https://github.com/crxjs/rollup-plugin-chrome-extension)
5
+ ![GitHub action badge](https://github.com/crxjs/chrome-extension-tools/actions/workflows/vite-plugin.yml/badge.svg)
7
6
 
8
- <a href="https://www.extend-chrome.dev/rollup-plugin" rel="noopener">
9
- <img width=200px height=200px src="https://imgur.com/wEXnCYK.png" alt="rollup-plugin-chrome-extension logo"></a>
7
+ ## CRXJS Vite Plugin
10
8
 
11
- The bundler configuration for a Chrome Extension can be pretty complex. This
12
- plugin makes it simple.
9
+ > Build a Chrome Extension with [Vite](https://vitejs.dev)⚡
13
10
 
14
- The manifest is front and center. Import your manifest to your config file and
15
- RPCE will do the rest.
11
+ CRXJS brings the Vite developer experience to Chrome Extensions:
16
12
 
17
- RPCE simplifies project config and supports many of Vite's features in the
18
- Chrome Extension environment, including HMR.
13
+ - True HMR for extension pages and content scripts
14
+ - Simple config - everything is in the extension manifest
15
+ - Static asset imports with automatic web-accessible resources
19
16
 
20
- ## Vite Usage (beta)
17
+ ## Getting Started
21
18
 
22
- Vite support is in beta! Check out this
23
- [90 second getting started guide](https://dev.to/jacksteamdev/create-a-vite-react-chrome-extension-in-90-seconds-3df7).
19
+ See the CRXJS documentation to
20
+ [get started in 90 seconds 🚀](https://crxjs.dev/vite-plugin)
24
21
 
25
- ```sh
26
- npm i rollup-plugin-chrome-extension@beta -D
27
- ```
22
+ ## Supporting
28
23
 
29
- ```javascript
30
- // vite.config.js
31
-
32
- import { defineConfig } from 'vite'
33
- import react from '@vitejs/plugin-react'
34
- import { crx } from 'rollup-plugin-chrome-extension'
35
- import manifest from './manifest.json'
36
-
37
- export default defineConfig({
38
- plugins: [react(), crx({ manifest })],
39
- })
40
- ```
41
-
42
- Just add new features to your manifest, and RPCE does the rest.
43
-
44
- ## [Documentation for v3](https://www.extend-chrome.dev/rollup-plugin)
45
-
46
- We have
47
- [v3 boilerplates](https://www.extend-chrome.dev/rollup-plugin#chrome-extension-boilerplates)
48
- for [React JavaScript](https://github.com/crxjs/js-react-boilerplate),
49
- [React TypeScript](https://github.com/crxjs/ts-react-boilerplate) and
50
- [Svelte](https://github.com/kyrelldixon/svelte-tailwind-extension-boilerplate),
51
- as well as [instructions](https://www.extend-chrome.dev/rollup-plugin#usage) for
52
- setting up your project.
53
-
54
- See the [documentation](https://www.extend-chrome.dev/rollup-plugin) for usage
55
- and how to get started.
24
+ If these plugins have helped you ship your product faster, please consider
25
+ [sponsoring me](https://github.com/sponsors/jacksteamdev) on GitHub.
56
26
 
57
27
  ## Contributing
58
28
 
59
- Your help is super welcome!
60
-
61
- 🎯 Ongoing development is for v4+ only.
62
-
63
- 👀 Be sure to take a look at the issues before starting to work on a new
64
- feature.
65
-
66
- 🙏 Please update the tests to cover bug fixes or new features.
67
-
68
- 📕 Documentation for v4 has not yet begun, but you can open an issue for help.
69
-
70
- ✨ If you enjoy using RPCE, please help spread the word!
71
-
72
- ## Development
73
-
74
- This monorepo uses [pnpm](https://pnpm.io/).
29
+ We encourage pull requests! This is a
30
+ [pnpm monorepo](https://pnpm.io/workspaces), so use pnpm instead of Yarn or npm.
package/dist/index.cjs CHANGED
@@ -70,8 +70,8 @@ async function manifestFiles(manifest, options = {}) {
70
70
  const serviceWorker = manifest.background?.service_worker;
71
71
  const htmlPages = htmlFiles(manifest);
72
72
  const icons = [
73
- Object.values(manifest.icons ?? {}),
74
- Object.values(manifest.action?.default_icon ?? {})
73
+ Object.values(isString(manifest.icons) ? [manifest.icons] : manifest.icons ?? {}),
74
+ Object.values(isString(manifest.action?.default_icon) ? [manifest.action?.default_icon] : manifest.action?.default_icon ?? {})
75
75
  ].flat();
76
76
  let webAccessibleResources = [];
77
77
  if (manifest.web_accessible_resources) {
@@ -3512,7 +3512,9 @@ const pluginBackground = () => {
3512
3512
  if (this.meta.watchMode) {
3513
3513
  if (typeof port === "undefined")
3514
3514
  throw new Error("server port is undefined in watch mode");
3515
- loader = `import 'http://localhost:${port}${workerClientId}';
3515
+ loader = `import 'http:/localhost:${port}/@vite/env';
3516
+ `;
3517
+ loader += `import 'http://localhost:${port}${workerClientId}';
3516
3518
  `;
3517
3519
  if (worker)
3518
3520
  loader += `import 'http://localhost:${port}/${worker}';
package/dist/index.mjs CHANGED
@@ -37,8 +37,8 @@ async function manifestFiles(manifest, options = {}) {
37
37
  const serviceWorker = manifest.background?.service_worker;
38
38
  const htmlPages = htmlFiles(manifest);
39
39
  const icons = [
40
- Object.values(manifest.icons ?? {}),
41
- Object.values(manifest.action?.default_icon ?? {})
40
+ Object.values(isString(manifest.icons) ? [manifest.icons] : manifest.icons ?? {}),
41
+ Object.values(isString(manifest.action?.default_icon) ? [manifest.action?.default_icon] : manifest.action?.default_icon ?? {})
42
42
  ].flat();
43
43
  let webAccessibleResources = [];
44
44
  if (manifest.web_accessible_resources) {
@@ -3479,7 +3479,9 @@ const pluginBackground = () => {
3479
3479
  if (this.meta.watchMode) {
3480
3480
  if (typeof port === "undefined")
3481
3481
  throw new Error("server port is undefined in watch mode");
3482
- loader = `import 'http://localhost:${port}${workerClientId}';
3482
+ loader = `import 'http:/localhost:${port}/@vite/env';
3483
+ `;
3484
+ loader += `import 'http://localhost:${port}${workerClientId}';
3483
3485
  `;
3484
3486
  if (worker)
3485
3487
  loader += `import 'http://localhost:${port}/${worker}';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crxjs/vite-plugin",
3
- "version": "1.0.9",
3
+ "version": "1.0.12",
4
4
  "description": "Build Chrome Extensions with this Vite plugin.",
5
5
  "keywords": [
6
6
  "rollup-plugin",
@@ -83,24 +83,24 @@
83
83
  "@rollup/plugin-commonjs": "21.1.0",
84
84
  "@rollup/plugin-node-resolve": "13.2.0",
85
85
  "@types/acorn": "4.0.6",
86
- "@types/chrome": "0.0.188",
86
+ "@types/chrome": "0.0.190",
87
87
  "@types/debug": "4.1.7",
88
88
  "@types/fs-extra": "9.0.13",
89
- "@types/jest": "27.5.1",
89
+ "@types/jest": "27.5.2",
90
90
  "@types/jest-image-snapshot": "4.3.1",
91
91
  "@types/jsesc": "3.0.1",
92
92
  "@types/node": "17.0.18",
93
93
  "@types/react": "17.0.44",
94
94
  "@types/react-dom": "17.0.17",
95
- "@typescript-eslint/eslint-plugin": "5.23.0",
96
- "@typescript-eslint/parser": "5.23.0",
95
+ "@typescript-eslint/eslint-plugin": "5.27.1",
96
+ "@typescript-eslint/parser": "5.27.1",
97
97
  "@vitejs/plugin-react": "1.3.2",
98
98
  "@vitejs/plugin-vue": "2.3.3",
99
- "esbuild": "0.14.42",
99
+ "esbuild": "0.14.43",
100
100
  "esbuild-runner": "2.2.1",
101
- "eslint": "8.15.0",
101
+ "eslint": "8.17.0",
102
102
  "jest": "27.5.1",
103
- "jest-image-snapshot": "4.5.1",
103
+ "jest-image-snapshot": "5.1.0",
104
104
  "playwright-chromium": "1.21.1",
105
105
  "react": "17.0.2",
106
106
  "react-dom": "17.0.2",
package/CHANGELOG.md DELETED
@@ -1,67 +0,0 @@
1
- # @crxjs/vite-plugin
2
-
3
- ## 1.0.9
4
-
5
- ### Patch Changes
6
-
7
- - 8941353: Remove & refactor use of fs-extra
8
-
9
- ## 1.0.8
10
-
11
- ### Patch Changes
12
-
13
- - 8a09cb9: Optimize rollup input
14
-
15
- ## 1.0.7
16
-
17
- ### Patch Changes
18
-
19
- - e1604d8: Strip paths from content script resource match patterns
20
-
21
- ## 1.0.6
22
-
23
- ### Patch Changes
24
-
25
- - 63d102f: Automatically ignores `build.outDir` for server HMR, so the file
26
- writer doesn't trigger a full reload.
27
-
28
- Fixes flaky HMR updates for content scripts; Tailwind should work fine now 🥳
29
-
30
- - a1e2728: Fix isImporter recursion
31
-
32
- ## 1.0.5
33
-
34
- ### Patch Changes
35
-
36
- - 86adbec: Sometimes during development, an extension page may open before the
37
- service worker has a chance to control fetch. The HTML file will load from the
38
- file system, but the script tag might load from the dev server. This PR adds a
39
- precontroller loader plugin to the dev server so that the extension page will
40
- reload and the fetch handler will get the real HTML file from the server.
41
-
42
- ## 1.0.4
43
-
44
- ### Patch Changes
45
-
46
- - b83a4bd: Check for manifest assets first in the project root, then check in
47
- the public dir. Throw an informative error if the file does not exist in
48
- either dir.
49
-
50
- ## 1.0.3
51
-
52
- ### Patch Changes
53
-
54
- - 8b2e587: check service worker on interval from extension page
55
-
56
- ## 1.0.2
57
-
58
- ### Patch Changes
59
-
60
- - be8a1de: Remove unused code that throws when web accessible resources contains
61
- an HTML file.
62
-
63
- ## 1.0.1
64
-
65
- ### Patch Changes
66
-
67
- - d2b4f9e: feat: allow hash in manifest html urls