@crxjs/vite-plugin 2.0.3 → 2.2.0
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.mjs +31 -4
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -107,9 +107,14 @@ const getMatchPatternOrigin = (pattern) => {
|
|
|
107
107
|
if (pattern.startsWith("<"))
|
|
108
108
|
return pattern;
|
|
109
109
|
const [schema, rest] = pattern.split("://");
|
|
110
|
-
const
|
|
110
|
+
const slashIndex = rest.indexOf("/");
|
|
111
|
+
const isSlashAfterOriginPresent = slashIndex !== -1;
|
|
112
|
+
const origin = isSlashAfterOriginPresent ? rest.slice(0, slashIndex) : rest;
|
|
111
113
|
const root = `${schema}://${origin}`;
|
|
112
|
-
|
|
114
|
+
if (isSlashAfterOriginPresent) {
|
|
115
|
+
return `${root}/*`;
|
|
116
|
+
}
|
|
117
|
+
return root;
|
|
113
118
|
};
|
|
114
119
|
|
|
115
120
|
function defineClientValues(code, config) {
|
|
@@ -1038,7 +1043,7 @@ function htmlFiles(manifest) {
|
|
|
1038
1043
|
manifest.options_ui?.page,
|
|
1039
1044
|
manifest.sandbox?.pages,
|
|
1040
1045
|
manifest.side_panel?.default_path
|
|
1041
|
-
].flat().filter(isString).map((s) => s.split(
|
|
1046
|
+
].flat().filter(isString).map((s) => s.split(/[#?]/)[0]).sort();
|
|
1042
1047
|
return [...new Set(files)];
|
|
1043
1048
|
}
|
|
1044
1049
|
|
|
@@ -1713,13 +1718,18 @@ const pluginManifest = () => {
|
|
|
1713
1718
|
let filename = join(config.root, f);
|
|
1714
1719
|
if (!existsSync(filename))
|
|
1715
1720
|
filename = join(config.publicDir, f);
|
|
1716
|
-
if (!existsSync(filename))
|
|
1721
|
+
if (!existsSync(filename)) {
|
|
1722
|
+
const viteMajorVersion = parseInt(version.split(".")[0]);
|
|
1723
|
+
if (viteMajorVersion < 4 && filename.endsWith(".map") && config.build.sourcemap === true) {
|
|
1724
|
+
return;
|
|
1725
|
+
}
|
|
1717
1726
|
throw new Error(
|
|
1718
1727
|
`ENOENT: Could not load manifest asset "${f}".
|
|
1719
1728
|
Manifest assets must exist in one of these directories:
|
|
1720
1729
|
Project root: "${config.root}"
|
|
1721
1730
|
Public dir: "${config.publicDir}"`
|
|
1722
1731
|
);
|
|
1732
|
+
}
|
|
1723
1733
|
this.emitFile({
|
|
1724
1734
|
type: "asset",
|
|
1725
1735
|
fileName: f,
|
|
@@ -1985,6 +1995,23 @@ const pluginWebAccessibleResources = () => {
|
|
|
1985
1995
|
delete war.use_dynamic_url;
|
|
1986
1996
|
}
|
|
1987
1997
|
}
|
|
1998
|
+
for (const war of combinedResources) {
|
|
1999
|
+
const resourcesWithMaps = [];
|
|
2000
|
+
for (const res of war.resources) {
|
|
2001
|
+
resourcesWithMaps.push(res);
|
|
2002
|
+
if (bundle[res]?.type === "chunk") {
|
|
2003
|
+
const chunk = bundle[res];
|
|
2004
|
+
if (chunk.map) {
|
|
2005
|
+
const sourcemapFileName = chunk.sourcemapFileName || `${chunk.fileName}.map`;
|
|
2006
|
+
const viteMajorVersion = parseInt(version.split(".")[0]);
|
|
2007
|
+
if (sourcemapFileName in bundle || viteMajorVersion < 4 && config.build.sourcemap == true) {
|
|
2008
|
+
resourcesWithMaps.push(sourcemapFileName);
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
war.resources = resourcesWithMaps;
|
|
2014
|
+
}
|
|
1988
2015
|
if (combinedResources.length === 0)
|
|
1989
2016
|
delete manifest.web_accessible_resources;
|
|
1990
2017
|
else
|