extension-develop 3.5.1 → 3.6.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/README.md +30 -15
- package/dist/215.cjs +40 -22
- package/dist/323.cjs +123 -5
- package/dist/{547.cjs → 535.cjs} +2156 -461
- package/dist/928.cjs +10 -0
- package/dist/content-script-wrapper.cjs +72 -4
- package/dist/main-world-bridge.cjs +18 -0
- package/dist/minimum-script-file.cjs +7 -5
- package/dist/module.cjs +1112 -404
- package/dist/warn-no-default-export.cjs +32 -5
- package/package.json +2 -1
|
@@ -39,6 +39,31 @@ const external_fs_namespaceObject = require("fs");
|
|
|
39
39
|
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
|
|
40
40
|
const external_path_namespaceObject = require("path");
|
|
41
41
|
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
42
|
+
function findUpLocalSync(filename, options) {
|
|
43
|
+
const root = external_path_namespaceObject.parse(options.cwd).root;
|
|
44
|
+
let currentDir = options.cwd;
|
|
45
|
+
while(true){
|
|
46
|
+
const candidate = external_path_namespaceObject.join(currentDir, filename);
|
|
47
|
+
try {
|
|
48
|
+
const stat = external_fs_namespaceObject.statSync(candidate);
|
|
49
|
+
if (stat.isFile()) return candidate;
|
|
50
|
+
} catch {}
|
|
51
|
+
if (currentDir === root) return;
|
|
52
|
+
currentDir = external_path_namespaceObject.dirname(currentDir);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function findNearestPackageJsonSync(manifestPath) {
|
|
56
|
+
try {
|
|
57
|
+
const manifestDir = external_path_namespaceObject.dirname(manifestPath);
|
|
58
|
+
const packageJsonPath = findUpLocalSync('package.json', {
|
|
59
|
+
cwd: manifestDir
|
|
60
|
+
});
|
|
61
|
+
return packageJsonPath || null;
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.warn('Failed to find package.json:', error);
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
42
67
|
const core_namespaceObject = require("@swc/core");
|
|
43
68
|
const external_schema_utils_namespaceObject = require("schema-utils");
|
|
44
69
|
const schema = {
|
|
@@ -197,7 +222,9 @@ function warn_no_default_export(source) {
|
|
|
197
222
|
});
|
|
198
223
|
try {
|
|
199
224
|
const resourceAbsPath = external_path_default().normalize(this.resourcePath);
|
|
200
|
-
const
|
|
225
|
+
const manifestDir = external_path_default().dirname(manifestPath);
|
|
226
|
+
const packageJsonPath = findNearestPackageJsonSync(manifestPath);
|
|
227
|
+
const packageJsonDir = packageJsonPath ? external_path_default().dirname(packageJsonPath) : manifestDir;
|
|
201
228
|
const compilation = this._compilation;
|
|
202
229
|
const dedupeKey = `no-default:${resourceAbsPath}`;
|
|
203
230
|
if (compilation) {
|
|
@@ -208,10 +235,10 @@ function warn_no_default_export(source) {
|
|
|
208
235
|
const contentScripts = Array.isArray(manifest.content_scripts) ? manifest.content_scripts : [];
|
|
209
236
|
for (const contentScript of contentScripts){
|
|
210
237
|
const contentScriptJsList = Array.isArray(contentScript?.js) ? contentScript.js : [];
|
|
211
|
-
for (const contentScriptJs of contentScriptJsList)declaredContentJsAbsPaths.push(external_path_default().resolve(
|
|
238
|
+
for (const contentScriptJs of contentScriptJsList)declaredContentJsAbsPaths.push(external_path_default().resolve(manifestDir, contentScriptJs));
|
|
212
239
|
}
|
|
213
240
|
const isDeclaredContentScript = declaredContentJsAbsPaths.some((abs)=>resourceAbsPath === external_path_default().normalize(abs));
|
|
214
|
-
const scriptsDir = external_path_default().resolve(
|
|
241
|
+
const scriptsDir = external_path_default().resolve(packageJsonDir, "scripts");
|
|
215
242
|
const relToScripts = external_path_default().relative(scriptsDir, resourceAbsPath);
|
|
216
243
|
const isScriptsFolderScript = relToScripts && !relToScripts.startsWith('..') && !external_path_default().isAbsolute(relToScripts);
|
|
217
244
|
const isContentScriptLike = isDeclaredContentScript || isScriptsFolderScript;
|
|
@@ -224,7 +251,7 @@ function warn_no_default_export(source) {
|
|
|
224
251
|
compilation.__extjsWarnedDefaultExportKinds ??= new Set();
|
|
225
252
|
if (compilation.__extjsWarnedDefaultExportKinds.has(dedupeKindKey)) return source;
|
|
226
253
|
}
|
|
227
|
-
const relativeFile = external_path_default().relative(
|
|
254
|
+
const relativeFile = external_path_default().relative(packageJsonDir, resourceAbsPath);
|
|
228
255
|
const found = 'class' === analysis.kind ? 'class' : 'non-callable value';
|
|
229
256
|
const message = [
|
|
230
257
|
"Content script default export must be a function.",
|
|
@@ -247,7 +274,7 @@ function warn_no_default_export(source) {
|
|
|
247
274
|
compilation?.__extjsWarnedDefaultExportKinds?.add(dedupeKindKey);
|
|
248
275
|
}
|
|
249
276
|
} else {
|
|
250
|
-
const relativeFile = external_path_default().relative(
|
|
277
|
+
const relativeFile = external_path_default().relative(packageJsonDir, resourceAbsPath);
|
|
251
278
|
const message = [
|
|
252
279
|
"Content script requires a default export.",
|
|
253
280
|
`File: ${relativeFile}`,
|
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"webpack/webpack-lib/build-dependencies.json"
|
|
25
25
|
],
|
|
26
26
|
"name": "extension-develop",
|
|
27
|
-
"version": "3.
|
|
27
|
+
"version": "3.6.0",
|
|
28
28
|
"description": "Develop, build, preview, and package Extension.js projects.",
|
|
29
29
|
"author": {
|
|
30
30
|
"name": "Cezar Augusto",
|
|
@@ -85,6 +85,7 @@
|
|
|
85
85
|
"cross-spawn": "^7.0.6",
|
|
86
86
|
"dotenv": "^17.2.3",
|
|
87
87
|
"edge-location": "2.2.0",
|
|
88
|
+
"extension-from-store": "^0.1.1",
|
|
88
89
|
"firefox-location2": "3.0.0",
|
|
89
90
|
"go-git-it": "^5.1.1",
|
|
90
91
|
"ignore": "^7.0.5",
|