@crxjs/vite-plugin 1.0.7 → 1.0.10
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/CHANGELOG.md +18 -0
- package/README.md +18 -62
- package/dist/index.cjs +27 -13
- package/dist/index.mjs +23 -9
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @crxjs/vite-plugin
|
|
2
2
|
|
|
3
|
+
## 1.0.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f35c49e: Update READMEs
|
|
8
|
+
|
|
9
|
+
## 1.0.9
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 8941353: Remove & refactor use of fs-extra
|
|
14
|
+
|
|
15
|
+
## 1.0.8
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 8a09cb9: Optimize rollup input
|
|
20
|
+
|
|
3
21
|
## 1.0.7
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,74 +1,30 @@
|
|
|
1
|
-
# [
|
|
1
|
+
# 
|
|
2
2
|
|
|
3
|
-
[](#typescript)
|
|
3
|
+
[](https://www.npmjs.com/package/rollup-plugin-chrome-extension)
|
|
4
|
+
[](https://github.com/crxjs/rollup-plugin-chrome-extension)
|
|
5
|
+

|
|
7
6
|
|
|
8
|
-
|
|
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
|
-
|
|
12
|
-
plugin makes it simple.
|
|
9
|
+
> Build a Chrome Extension with [Vite](https://vitejs.dev)⚡
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
RPCE will do the rest.
|
|
11
|
+
CRXJS brings the Vite developer experience to Chrome Extensions:
|
|
16
12
|
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
##
|
|
17
|
+
## Getting Started
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
[
|
|
19
|
+
See the CRXJS documentation to
|
|
20
|
+
[get started in 90 seconds 🚀](https://crxjs.dev/vite-plugin)
|
|
24
21
|
|
|
25
|
-
|
|
26
|
-
npm i rollup-plugin-chrome-extension@beta -D
|
|
27
|
-
```
|
|
22
|
+
## Supporting
|
|
28
23
|
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
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
|
@@ -8,16 +8,16 @@ var crypto = require('crypto');
|
|
|
8
8
|
var debug$5 = require('debug');
|
|
9
9
|
var fg = require('fast-glob');
|
|
10
10
|
var v8 = require('v8');
|
|
11
|
-
var
|
|
11
|
+
var fs = require('fs');
|
|
12
12
|
var MagicString = require('magic-string');
|
|
13
13
|
var path = require('path');
|
|
14
|
+
var fsExtra = require('fs-extra');
|
|
14
15
|
var perf_hooks = require('perf_hooks');
|
|
15
16
|
var colors = require('picocolors');
|
|
16
17
|
var vite = require('vite');
|
|
17
18
|
var module$1 = require('module');
|
|
18
19
|
var cheerio = require('cheerio');
|
|
19
20
|
var jsesc = require('jsesc');
|
|
20
|
-
var fs = require('fs');
|
|
21
21
|
var injector = require('connect-injector');
|
|
22
22
|
|
|
23
23
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -43,8 +43,8 @@ function _interopNamespace(e) {
|
|
|
43
43
|
var debug__default = /*#__PURE__*/_interopDefaultLegacy(debug$5);
|
|
44
44
|
var fg__default = /*#__PURE__*/_interopDefaultLegacy(fg);
|
|
45
45
|
var v8__default = /*#__PURE__*/_interopDefaultLegacy(v8);
|
|
46
|
-
var fsExtra__default = /*#__PURE__*/_interopDefaultLegacy(fsExtra);
|
|
47
46
|
var MagicString__default = /*#__PURE__*/_interopDefaultLegacy(MagicString);
|
|
47
|
+
var fsExtra__default = /*#__PURE__*/_interopDefaultLegacy(fsExtra);
|
|
48
48
|
var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
|
|
49
49
|
var jsesc__default = /*#__PURE__*/_interopDefaultLegacy(jsesc);
|
|
50
50
|
var injector__default = /*#__PURE__*/_interopDefaultLegacy(injector);
|
|
@@ -218,6 +218,7 @@ const preambleId = "/crx-client-preamble";
|
|
|
218
218
|
const stubId = "/crx-stub";
|
|
219
219
|
const workerClientId = "/crx-client-worker";
|
|
220
220
|
|
|
221
|
+
const { readFile: readFile$2 } = fs.promises;
|
|
221
222
|
const debug$4 = _debug("file-writer").extend("chunks");
|
|
222
223
|
for (const source of [viteClientId, customElementsId]) {
|
|
223
224
|
setUrlMeta(sourceToUrlMeta(source));
|
|
@@ -292,7 +293,7 @@ const pluginFileWriterChunks = () => {
|
|
|
292
293
|
this.emitFile({
|
|
293
294
|
type: "asset",
|
|
294
295
|
fileName: relative(server.config.root, file),
|
|
295
|
-
source: await
|
|
296
|
+
source: await readFile$2(file)
|
|
296
297
|
});
|
|
297
298
|
}
|
|
298
299
|
if (url)
|
|
@@ -2304,6 +2305,7 @@ const pluginFileWriterHtml = () => {
|
|
|
2304
2305
|
};
|
|
2305
2306
|
};
|
|
2306
2307
|
|
|
2308
|
+
const { readFile: readFile$1 } = fs.promises;
|
|
2307
2309
|
const pluginFileWriterPublic = () => {
|
|
2308
2310
|
let config;
|
|
2309
2311
|
return {
|
|
@@ -2317,7 +2319,7 @@ const pluginFileWriterPublic = () => {
|
|
|
2317
2319
|
this.addWatchFile(config.publicDir);
|
|
2318
2320
|
const publicFiles = await fg__default["default"](`${config.publicDir}/**/*`);
|
|
2319
2321
|
for (const file of publicFiles) {
|
|
2320
|
-
const source = await
|
|
2322
|
+
const source = await readFile$1(file);
|
|
2321
2323
|
const fileName = relative(config.publicDir, file);
|
|
2322
2324
|
this.emitFile({ type: "asset", fileName, source });
|
|
2323
2325
|
}
|
|
@@ -2328,8 +2330,8 @@ const pluginFileWriterPublic = () => {
|
|
|
2328
2330
|
|
|
2329
2331
|
const _require = typeof require === "undefined" ? module$1.createRequire((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href))) : require;
|
|
2330
2332
|
const customElementsPath = _require.resolve(customElementsId);
|
|
2331
|
-
const customElementsCode =
|
|
2332
|
-
const customElementsMap =
|
|
2333
|
+
const customElementsCode = fs.readFileSync(customElementsPath, "utf8");
|
|
2334
|
+
const customElementsMap = fs.readFileSync(`${customElementsPath}.map`, "utf8");
|
|
2333
2335
|
const pluginFileWriterPolyfill = () => {
|
|
2334
2336
|
return {
|
|
2335
2337
|
name: "crx:file-writer-polyfill",
|
|
@@ -2772,6 +2774,7 @@ const pluginHtmlAuditor = () => {
|
|
|
2772
2774
|
};
|
|
2773
2775
|
};
|
|
2774
2776
|
|
|
2777
|
+
const { readFile } = fs.promises;
|
|
2775
2778
|
const pluginManifest = (_manifest) => () => {
|
|
2776
2779
|
let manifest;
|
|
2777
2780
|
let plugins;
|
|
@@ -2784,17 +2787,28 @@ const pluginManifest = (_manifest) => () => {
|
|
|
2784
2787
|
async config(config2, env) {
|
|
2785
2788
|
manifest = await (typeof _manifest === "function" ? _manifest(env) : _manifest);
|
|
2786
2789
|
if (manifest.manifest_version !== 3)
|
|
2787
|
-
throw new Error(`Manifest v${manifest.manifest_version}
|
|
2790
|
+
throw new Error(`CRXJS does not support Manifest v${manifest.manifest_version}, please use Manifest v3`);
|
|
2788
2791
|
if (env.command === "serve") {
|
|
2789
2792
|
const {
|
|
2790
2793
|
contentScripts: js,
|
|
2791
2794
|
background: sw,
|
|
2792
2795
|
html
|
|
2793
2796
|
} = await manifestFiles(manifest);
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2797
|
+
const { entries = [] } = config2.optimizeDeps ?? {};
|
|
2798
|
+
let { input = [] } = config2.build?.rollupOptions ?? {};
|
|
2799
|
+
if (typeof input === "string")
|
|
2800
|
+
input = [input];
|
|
2801
|
+
else
|
|
2802
|
+
input = Object.values(input);
|
|
2803
|
+
input = input.map((f) => {
|
|
2804
|
+
let result = f;
|
|
2805
|
+
if (isAbsolute(f)) {
|
|
2806
|
+
result = relative(config2.root ?? process.cwd(), f);
|
|
2807
|
+
}
|
|
2808
|
+
return result;
|
|
2809
|
+
});
|
|
2810
|
+
const set = new Set([entries, input].flat());
|
|
2811
|
+
for (const x of [js, sw, html].flat())
|
|
2798
2812
|
set.add(x);
|
|
2799
2813
|
return {
|
|
2800
2814
|
...config2,
|
|
@@ -2969,7 +2983,7 @@ Public dir: "${config.publicDir}"`);
|
|
|
2969
2983
|
this.emitFile({
|
|
2970
2984
|
type: "asset",
|
|
2971
2985
|
fileName: f,
|
|
2972
|
-
source: await
|
|
2986
|
+
source: await readFile(filename)
|
|
2973
2987
|
});
|
|
2974
2988
|
}
|
|
2975
2989
|
}));
|
package/dist/index.mjs
CHANGED
|
@@ -4,16 +4,16 @@ import { createHash as createHash$1 } from 'crypto';
|
|
|
4
4
|
import debug$5 from 'debug';
|
|
5
5
|
import fg from 'fast-glob';
|
|
6
6
|
import v8 from 'v8';
|
|
7
|
-
import
|
|
7
|
+
import { promises, readFileSync, existsSync } from 'fs';
|
|
8
8
|
import MagicString from 'magic-string';
|
|
9
9
|
import { posix } from 'path';
|
|
10
|
+
import fsExtra from 'fs-extra';
|
|
10
11
|
import { performance } from 'perf_hooks';
|
|
11
12
|
import colors from 'picocolors';
|
|
12
13
|
import { createLogger } from 'vite';
|
|
13
14
|
import { createRequire } from 'module';
|
|
14
15
|
import { load } from 'cheerio';
|
|
15
16
|
import jsesc from 'jsesc';
|
|
16
|
-
import { existsSync } from 'fs';
|
|
17
17
|
import injector from 'connect-injector';
|
|
18
18
|
|
|
19
19
|
const _debug = (id) => debug$5("crx").extend(id);
|
|
@@ -185,6 +185,7 @@ const preambleId = "/crx-client-preamble";
|
|
|
185
185
|
const stubId = "/crx-stub";
|
|
186
186
|
const workerClientId = "/crx-client-worker";
|
|
187
187
|
|
|
188
|
+
const { readFile: readFile$2 } = promises;
|
|
188
189
|
const debug$4 = _debug("file-writer").extend("chunks");
|
|
189
190
|
for (const source of [viteClientId, customElementsId]) {
|
|
190
191
|
setUrlMeta(sourceToUrlMeta(source));
|
|
@@ -259,7 +260,7 @@ const pluginFileWriterChunks = () => {
|
|
|
259
260
|
this.emitFile({
|
|
260
261
|
type: "asset",
|
|
261
262
|
fileName: relative(server.config.root, file),
|
|
262
|
-
source: await readFile(file)
|
|
263
|
+
source: await readFile$2(file)
|
|
263
264
|
});
|
|
264
265
|
}
|
|
265
266
|
if (url)
|
|
@@ -2271,6 +2272,7 @@ const pluginFileWriterHtml = () => {
|
|
|
2271
2272
|
};
|
|
2272
2273
|
};
|
|
2273
2274
|
|
|
2275
|
+
const { readFile: readFile$1 } = promises;
|
|
2274
2276
|
const pluginFileWriterPublic = () => {
|
|
2275
2277
|
let config;
|
|
2276
2278
|
return {
|
|
@@ -2284,7 +2286,7 @@ const pluginFileWriterPublic = () => {
|
|
|
2284
2286
|
this.addWatchFile(config.publicDir);
|
|
2285
2287
|
const publicFiles = await fg(`${config.publicDir}/**/*`);
|
|
2286
2288
|
for (const file of publicFiles) {
|
|
2287
|
-
const source = await readFile(file);
|
|
2289
|
+
const source = await readFile$1(file);
|
|
2288
2290
|
const fileName = relative(config.publicDir, file);
|
|
2289
2291
|
this.emitFile({ type: "asset", fileName, source });
|
|
2290
2292
|
}
|
|
@@ -2739,6 +2741,7 @@ const pluginHtmlAuditor = () => {
|
|
|
2739
2741
|
};
|
|
2740
2742
|
};
|
|
2741
2743
|
|
|
2744
|
+
const { readFile } = promises;
|
|
2742
2745
|
const pluginManifest = (_manifest) => () => {
|
|
2743
2746
|
let manifest;
|
|
2744
2747
|
let plugins;
|
|
@@ -2751,17 +2754,28 @@ const pluginManifest = (_manifest) => () => {
|
|
|
2751
2754
|
async config(config2, env) {
|
|
2752
2755
|
manifest = await (typeof _manifest === "function" ? _manifest(env) : _manifest);
|
|
2753
2756
|
if (manifest.manifest_version !== 3)
|
|
2754
|
-
throw new Error(`Manifest v${manifest.manifest_version}
|
|
2757
|
+
throw new Error(`CRXJS does not support Manifest v${manifest.manifest_version}, please use Manifest v3`);
|
|
2755
2758
|
if (env.command === "serve") {
|
|
2756
2759
|
const {
|
|
2757
2760
|
contentScripts: js,
|
|
2758
2761
|
background: sw,
|
|
2759
2762
|
html
|
|
2760
2763
|
} = await manifestFiles(manifest);
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2764
|
+
const { entries = [] } = config2.optimizeDeps ?? {};
|
|
2765
|
+
let { input = [] } = config2.build?.rollupOptions ?? {};
|
|
2766
|
+
if (typeof input === "string")
|
|
2767
|
+
input = [input];
|
|
2768
|
+
else
|
|
2769
|
+
input = Object.values(input);
|
|
2770
|
+
input = input.map((f) => {
|
|
2771
|
+
let result = f;
|
|
2772
|
+
if (isAbsolute(f)) {
|
|
2773
|
+
result = relative(config2.root ?? process.cwd(), f);
|
|
2774
|
+
}
|
|
2775
|
+
return result;
|
|
2776
|
+
});
|
|
2777
|
+
const set = new Set([entries, input].flat());
|
|
2778
|
+
for (const x of [js, sw, html].flat())
|
|
2765
2779
|
set.add(x);
|
|
2766
2780
|
return {
|
|
2767
2781
|
...config2,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crxjs/vite-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "Build Chrome Extensions with this Vite plugin.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rollup-plugin",
|
|
@@ -95,8 +95,8 @@
|
|
|
95
95
|
"@typescript-eslint/eslint-plugin": "5.23.0",
|
|
96
96
|
"@typescript-eslint/parser": "5.23.0",
|
|
97
97
|
"@vitejs/plugin-react": "1.3.2",
|
|
98
|
-
"@vitejs/plugin-vue": "2.3.
|
|
99
|
-
"esbuild": "0.14.
|
|
98
|
+
"@vitejs/plugin-vue": "2.3.3",
|
|
99
|
+
"esbuild": "0.14.42",
|
|
100
100
|
"esbuild-runner": "2.2.1",
|
|
101
101
|
"eslint": "8.15.0",
|
|
102
102
|
"jest": "27.5.1",
|