@crxjs/vite-plugin 2.0.0-beta.16 → 2.0.0-beta.18
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.d.ts +8 -5
- package/dist/index.mjs +31 -7
- package/package.json +12 -10
package/dist/index.d.ts
CHANGED
|
@@ -118,12 +118,12 @@ interface ManifestV3 {
|
|
|
118
118
|
} | undefined;
|
|
119
119
|
incognito?: string | undefined;
|
|
120
120
|
input_components?: {
|
|
121
|
-
name
|
|
122
|
-
type?: string | undefined;
|
|
121
|
+
name: string;
|
|
123
122
|
id?: string | undefined;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
123
|
+
language?: string | string[] | undefined;
|
|
124
|
+
layouts?: string | string[] | undefined;
|
|
125
|
+
input_view?: string | undefined;
|
|
126
|
+
options_page?: string | undefined;
|
|
127
127
|
}[] | undefined;
|
|
128
128
|
key?: string | undefined;
|
|
129
129
|
minimum_chrome_version?: string | undefined;
|
|
@@ -166,6 +166,9 @@ interface ManifestV3 {
|
|
|
166
166
|
pages: string[];
|
|
167
167
|
content_security_policy?: string | undefined;
|
|
168
168
|
} | undefined;
|
|
169
|
+
side_panel?: {
|
|
170
|
+
default_path?: string | undefined;
|
|
171
|
+
} | undefined;
|
|
169
172
|
short_name?: string | undefined;
|
|
170
173
|
spellcheck?: {
|
|
171
174
|
dictionary_language?: string | undefined;
|
package/dist/index.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import { rollup } from 'rollup';
|
|
|
10
10
|
import * as lexer from 'es-module-lexer';
|
|
11
11
|
import { readFile as readFile$1 } from 'fs/promises';
|
|
12
12
|
import MagicString from 'magic-string';
|
|
13
|
+
import convertSourceMap from 'convert-source-map';
|
|
13
14
|
import { createLogger } from 'vite';
|
|
14
15
|
import { readFileSync, existsSync, promises } from 'fs';
|
|
15
16
|
import { createRequire } from 'module';
|
|
@@ -441,8 +442,25 @@ function prepScript(fileName, script) {
|
|
|
441
442
|
const transformResult = await server.transformRequest(viteUrl);
|
|
442
443
|
if (!transformResult)
|
|
443
444
|
throw new TypeError(`Unable to load "${script.id}" from server.`);
|
|
444
|
-
const {
|
|
445
|
-
|
|
445
|
+
const { deps = [], dynamicDeps = [], map: map2 } = transformResult;
|
|
446
|
+
let { code } = transformResult;
|
|
447
|
+
try {
|
|
448
|
+
if (map2 && server.config.build.sourcemap === "inline") {
|
|
449
|
+
code = code.replace(/\n*\/\/# sourceMappingURL=[^\n]+/g, "");
|
|
450
|
+
const sourceMap = convertSourceMap.fromObject(map2).toComment();
|
|
451
|
+
code += `
|
|
452
|
+
${sourceMap}
|
|
453
|
+
`;
|
|
454
|
+
}
|
|
455
|
+
} catch (error) {
|
|
456
|
+
console.warn("Failed to inline source map", error);
|
|
457
|
+
}
|
|
458
|
+
return {
|
|
459
|
+
target,
|
|
460
|
+
code,
|
|
461
|
+
deps: [...deps, ...dynamicDeps].flat(),
|
|
462
|
+
server
|
|
463
|
+
};
|
|
446
464
|
}),
|
|
447
465
|
// retry in case of dependency rebundle
|
|
448
466
|
retry({ count: 10, delay: 100 }),
|
|
@@ -1004,7 +1022,8 @@ function htmlFiles(manifest) {
|
|
|
1004
1022
|
manifest.devtools_page,
|
|
1005
1023
|
manifest.options_page,
|
|
1006
1024
|
manifest.options_ui?.page,
|
|
1007
|
-
manifest.sandbox?.pages
|
|
1025
|
+
manifest.sandbox?.pages,
|
|
1026
|
+
manifest.side_panel?.default_path
|
|
1008
1027
|
].flat().filter(isString).map((s) => s.split("#")[0]).sort();
|
|
1009
1028
|
return [...new Set(files)];
|
|
1010
1029
|
}
|
|
@@ -1568,7 +1587,7 @@ const pluginManifest = () => {
|
|
|
1568
1587
|
}
|
|
1569
1588
|
}
|
|
1570
1589
|
const encoded = encodeManifest(manifest2);
|
|
1571
|
-
return encoded;
|
|
1590
|
+
return { code: encoded, map: null };
|
|
1572
1591
|
},
|
|
1573
1592
|
async generateBundle(options, bundle) {
|
|
1574
1593
|
const manifestName = this.getFileName(refId);
|
|
@@ -1694,7 +1713,11 @@ function compileFileResources(fileName, {
|
|
|
1694
1713
|
assets: /* @__PURE__ */ new Set(),
|
|
1695
1714
|
css: /* @__PURE__ */ new Set(),
|
|
1696
1715
|
imports: /* @__PURE__ */ new Set()
|
|
1697
|
-
}) {
|
|
1716
|
+
}, processedFiles = /* @__PURE__ */ new Set()) {
|
|
1717
|
+
if (processedFiles.has(fileName)) {
|
|
1718
|
+
return resources;
|
|
1719
|
+
}
|
|
1720
|
+
processedFiles.add(fileName);
|
|
1698
1721
|
const chunk = chunks.get(fileName);
|
|
1699
1722
|
if (chunk) {
|
|
1700
1723
|
const { modules, facadeModuleId, imports, dynamicImports } = chunk;
|
|
@@ -1703,7 +1726,7 @@ function compileFileResources(fileName, {
|
|
|
1703
1726
|
for (const x of dynamicImports)
|
|
1704
1727
|
resources.imports.add(x);
|
|
1705
1728
|
for (const x of [...imports, ...dynamicImports])
|
|
1706
|
-
compileFileResources(x, { chunks, files, config }, resources);
|
|
1729
|
+
compileFileResources(x, { chunks, files, config }, resources, processedFiles);
|
|
1707
1730
|
for (const m of Object.keys(modules))
|
|
1708
1731
|
if (m !== facadeModuleId) {
|
|
1709
1732
|
const key = prefix$1("/", relative(config.root, m.split("?")[0]));
|
|
@@ -1716,7 +1739,8 @@ function compileFileResources(fileName, {
|
|
|
1716
1739
|
compileFileResources(
|
|
1717
1740
|
script.fileName,
|
|
1718
1741
|
{ chunks, files, config },
|
|
1719
|
-
resources
|
|
1742
|
+
resources,
|
|
1743
|
+
processedFiles
|
|
1720
1744
|
);
|
|
1721
1745
|
}
|
|
1722
1746
|
}
|
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.18",
|
|
4
4
|
"description": "Build Chrome Extensions with this Vite plugin.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rollup-plugin",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"type": "module",
|
|
27
27
|
"exports": {
|
|
28
28
|
".": {
|
|
29
|
-
"require": "./index.cjs",
|
|
29
|
+
"require": "./dist/index.cjs",
|
|
30
30
|
"import": "./dist/index.mjs",
|
|
31
31
|
"types": "./dist/index.d.ts"
|
|
32
32
|
},
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"acorn-walk": "^8.2.0",
|
|
69
69
|
"cheerio": "^1.0.0-rc.10",
|
|
70
70
|
"connect-injector": "^0.4.4",
|
|
71
|
+
"convert-source-map": "^1.7.0",
|
|
71
72
|
"debug": "^4.3.3",
|
|
72
73
|
"es-module-lexer": "^0.10.0",
|
|
73
74
|
"fast-glob": "^3.2.11",
|
|
@@ -82,13 +83,14 @@
|
|
|
82
83
|
"devDependencies": {
|
|
83
84
|
"@extend-chrome/messages": "1.2.2",
|
|
84
85
|
"@extend-chrome/storage": "1.5.0",
|
|
85
|
-
"@rollup/plugin-alias": "4.0.
|
|
86
|
+
"@rollup/plugin-alias": "4.0.4",
|
|
86
87
|
"@rollup/plugin-commonjs": "21.1.0",
|
|
87
88
|
"@rollup/plugin-json": "^5.0.0",
|
|
88
89
|
"@rollup/plugin-node-resolve": "13.2.0",
|
|
89
|
-
"@sveltejs/vite-plugin-svelte": "1.
|
|
90
|
+
"@sveltejs/vite-plugin-svelte": "1.4.0",
|
|
90
91
|
"@types/acorn": "4.0.6",
|
|
91
|
-
"@types/chrome": "0.0.
|
|
92
|
+
"@types/chrome": "0.0.237",
|
|
93
|
+
"@types/convert-source-map": "^2.0.0",
|
|
92
94
|
"@types/debug": "4.1.7",
|
|
93
95
|
"@types/fs-extra": "9.0.13",
|
|
94
96
|
"@types/jest-image-snapshot": "^5.1.0",
|
|
@@ -103,21 +105,21 @@
|
|
|
103
105
|
"chokidar": "^3.5.3",
|
|
104
106
|
"esbuild": "0.17.14",
|
|
105
107
|
"esbuild-runner": "2.2.2",
|
|
106
|
-
"eslint": "8.
|
|
108
|
+
"eslint": "8.43.0",
|
|
107
109
|
"eslint-plugin-react": "^7.29.4",
|
|
108
110
|
"jest-image-snapshot": "^5.2.0",
|
|
109
111
|
"npm-run-all": "^4.1.5",
|
|
110
|
-
"playwright-chromium": "1.
|
|
112
|
+
"playwright-chromium": "1.33.0",
|
|
111
113
|
"react": "17.0.2",
|
|
112
114
|
"react-dom": "17.0.2",
|
|
113
115
|
"rimraf": "3.0.2",
|
|
114
116
|
"rollup-plugin-dts": "^4.2.0",
|
|
115
|
-
"rollup-plugin-esbuild": "4.10.
|
|
117
|
+
"rollup-plugin-esbuild": "4.10.3",
|
|
116
118
|
"svelte": "^3.48.0",
|
|
117
119
|
"typescript": "^4.6.4",
|
|
118
120
|
"vite": "^3.1.7",
|
|
119
|
-
"vite-plugin-inspect": "0.7.
|
|
121
|
+
"vite-plugin-inspect": "0.7.25",
|
|
120
122
|
"vitest": "0.28.5",
|
|
121
|
-
"vue": "3.2.
|
|
123
|
+
"vue": "3.2.47"
|
|
122
124
|
}
|
|
123
125
|
}
|