@crxjs/vite-plugin 2.0.0-beta.3 → 2.0.0-beta.5
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/dist/index.cjs +0 -1848
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +10 -9
- package/package.json +12 -12
package/dist/index.d.ts
CHANGED
|
@@ -202,7 +202,8 @@ declare const defineManifest: (manifest: ManifestV3Export) => ManifestV3Export;
|
|
|
202
202
|
*
|
|
203
203
|
* You don't need to define a match pattern for dynamic content script
|
|
204
204
|
* resources, but if you want to do so, you can use the helper function
|
|
205
|
-
* `defineDynamicResource` to define your web accessible resources in a
|
|
205
|
+
* `defineDynamicResource` to define your web accessible resources in a
|
|
206
|
+
* TypeScript file:
|
|
206
207
|
*
|
|
207
208
|
* ```typescript
|
|
208
209
|
* import { crx, defineManifest, defineDynamicResource }
|
package/dist/index.mjs
CHANGED
|
@@ -14,7 +14,6 @@ import { createLogger } from 'vite';
|
|
|
14
14
|
import { readFileSync, existsSync, promises } from 'fs';
|
|
15
15
|
import { createRequire } from 'module';
|
|
16
16
|
import fg from 'fast-glob';
|
|
17
|
-
import getPort, { portNumbers } from 'get-port';
|
|
18
17
|
import { load } from 'cheerio';
|
|
19
18
|
import jsesc from 'jsesc';
|
|
20
19
|
import colors from 'picocolors';
|
|
@@ -30,12 +29,15 @@ const pluginOptionsProvider = (options) => {
|
|
|
30
29
|
}
|
|
31
30
|
};
|
|
32
31
|
};
|
|
33
|
-
const getOptions = ({
|
|
32
|
+
const getOptions = async ({
|
|
33
|
+
plugins
|
|
34
|
+
}) => {
|
|
34
35
|
if (typeof plugins === "undefined") {
|
|
35
36
|
throw new Error("config.plugins is undefined");
|
|
36
37
|
}
|
|
38
|
+
const awaitedPlugins = await Promise.all(plugins);
|
|
37
39
|
let options;
|
|
38
|
-
for (const p of
|
|
40
|
+
for (const p of awaitedPlugins.flat()) {
|
|
39
41
|
if (isCrxPlugin(p)) {
|
|
40
42
|
if (p.name === pluginName$1) {
|
|
41
43
|
const plugin = p;
|
|
@@ -558,8 +560,8 @@ const pluginContentScripts = () => {
|
|
|
558
560
|
{
|
|
559
561
|
name: "crx:content-scripts",
|
|
560
562
|
apply: "serve",
|
|
561
|
-
config(config) {
|
|
562
|
-
const { contentScripts: contentScripts2 = {} } = getOptions(config);
|
|
563
|
+
async config(config) {
|
|
564
|
+
const { contentScripts: contentScripts2 = {} } = await getOptions(config);
|
|
563
565
|
hmrTimeout = contentScripts2.hmrTimeout ?? 5e3;
|
|
564
566
|
preambleCode = preambleCode ?? contentScripts2.preambleCode;
|
|
565
567
|
},
|
|
@@ -661,8 +663,8 @@ const pluginContentScriptsCss = () => {
|
|
|
661
663
|
return {
|
|
662
664
|
name: "crx:content-scripts-css",
|
|
663
665
|
enforce: "post",
|
|
664
|
-
config(config) {
|
|
665
|
-
const { contentScripts: contentScripts2 = {} } = getOptions(config);
|
|
666
|
+
async config(config) {
|
|
667
|
+
const { contentScripts: contentScripts2 = {} } = await getOptions(config);
|
|
666
668
|
injectCss = contentScripts2.injectCss ?? true;
|
|
667
669
|
},
|
|
668
670
|
renderCrxManifest(manifest) {
|
|
@@ -691,7 +693,7 @@ const pluginDeclaredContentScripts = () => {
|
|
|
691
693
|
return [];
|
|
692
694
|
};
|
|
693
695
|
|
|
694
|
-
const _dynamicScriptRegEx = /\b(import.meta).CRX_DYNAMIC_SCRIPT_(.+?)
|
|
696
|
+
const _dynamicScriptRegEx = /\b(import.meta).CRX_DYNAMIC_SCRIPT_(.+?)[,;]/gm;
|
|
695
697
|
const dynamicScriptRegEx = () => {
|
|
696
698
|
_dynamicScriptRegEx.lastIndex = 0;
|
|
697
699
|
return _dynamicScriptRegEx;
|
|
@@ -1061,7 +1063,6 @@ const pluginHMR = () => {
|
|
|
1061
1063
|
server.hmr = {};
|
|
1062
1064
|
server.hmr = server.hmr ?? {};
|
|
1063
1065
|
server.hmr.host = "localhost";
|
|
1064
|
-
server.hmr.port = server.hmr.port ?? await getPort({ port: portNumbers(5200, 5300) });
|
|
1065
1066
|
return { server, ...config2 };
|
|
1066
1067
|
},
|
|
1067
1068
|
configResolved(_config) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crxjs/vite-plugin",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.5",
|
|
4
4
|
"description": "Build Chrome Extensions with this Vite plugin.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rollup-plugin",
|
|
@@ -23,9 +23,10 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"author": "Jack and Amy Steam <jacksteamdev@gmail.com>",
|
|
26
|
+
"type": "module",
|
|
26
27
|
"exports": {
|
|
27
28
|
".": {
|
|
28
|
-
"require": "./
|
|
29
|
+
"require": "./index.cjs",
|
|
29
30
|
"import": "./dist/index.mjs",
|
|
30
31
|
"types": "./dist/index.d.ts"
|
|
31
32
|
},
|
|
@@ -71,7 +72,6 @@
|
|
|
71
72
|
"es-module-lexer": "^0.10.0",
|
|
72
73
|
"fast-glob": "^3.2.11",
|
|
73
74
|
"fs-extra": "^10.0.1",
|
|
74
|
-
"get-port": "^6.1.2",
|
|
75
75
|
"jsesc": "^3.0.2",
|
|
76
76
|
"magic-string": "^0.26.0",
|
|
77
77
|
"picocolors": "^1.0.0",
|
|
@@ -82,11 +82,11 @@
|
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"@extend-chrome/messages": "1.2.2",
|
|
84
84
|
"@extend-chrome/storage": "1.5.0",
|
|
85
|
-
"@rollup/plugin-alias": "
|
|
85
|
+
"@rollup/plugin-alias": "4.0.2",
|
|
86
86
|
"@rollup/plugin-commonjs": "21.1.0",
|
|
87
87
|
"@rollup/plugin-json": "^4.1.0",
|
|
88
88
|
"@rollup/plugin-node-resolve": "13.2.0",
|
|
89
|
-
"@sveltejs/vite-plugin-svelte": "1.0
|
|
89
|
+
"@sveltejs/vite-plugin-svelte": "1.1.0",
|
|
90
90
|
"@types/acorn": "4.0.6",
|
|
91
91
|
"@types/chrome": "0.0.198",
|
|
92
92
|
"@types/debug": "4.1.7",
|
|
@@ -94,16 +94,16 @@
|
|
|
94
94
|
"@types/jest-image-snapshot": "^5.1.0",
|
|
95
95
|
"@types/jsesc": "3.0.1",
|
|
96
96
|
"@types/node": "17.0.18",
|
|
97
|
-
"@types/react": "17.0.
|
|
98
|
-
"@types/react-dom": "17.0.
|
|
99
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
100
|
-
"@typescript-eslint/parser": "5.
|
|
97
|
+
"@types/react": "17.0.52",
|
|
98
|
+
"@types/react-dom": "17.0.18",
|
|
99
|
+
"@typescript-eslint/eslint-plugin": "5.41.0",
|
|
100
|
+
"@typescript-eslint/parser": "5.41.0",
|
|
101
101
|
"@vitejs/plugin-react": "^2.1.0",
|
|
102
|
-
"@vitejs/plugin-vue": "3.
|
|
102
|
+
"@vitejs/plugin-vue": "3.2.0",
|
|
103
103
|
"chokidar": "^3.5.3",
|
|
104
104
|
"esbuild": "0.15.12",
|
|
105
105
|
"esbuild-runner": "2.2.2",
|
|
106
|
-
"eslint": "8.
|
|
106
|
+
"eslint": "8.26.0",
|
|
107
107
|
"eslint-plugin-react": "^7.29.4",
|
|
108
108
|
"jest-image-snapshot": "^5.2.0",
|
|
109
109
|
"npm-run-all": "^4.1.5",
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
"typescript": "^4.6.4",
|
|
118
118
|
"vite": "^3.1.7",
|
|
119
119
|
"vite-plugin-inspect": "0.7.5",
|
|
120
|
-
"vitest": "
|
|
120
|
+
"vitest": "0.24.3",
|
|
121
121
|
"vue": "3.2.41"
|
|
122
122
|
}
|
|
123
123
|
}
|