wxt 0.14.1 → 0.14.2
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/{chunk-B7XRXAP5.js → chunk-TX6NW7VP.js} +60 -25
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +131 -76
- package/dist/{external-tVP-84Pg.d.cts → external-QOQPHF1G.d.cts} +7 -0
- package/dist/{external-tVP-84Pg.d.ts → external-QOQPHF1G.d.ts} +7 -0
- package/dist/index.cjs +97 -60
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -1
- package/dist/testing.cjs +19 -15
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2615,6 +2615,7 @@ function resolvePerBrowserOption(option, browser) {
|
|
|
2615
2615
|
var VIRTUAL_NOOP_BACKGROUND_MODULE_ID = "virtual:user-background";
|
|
2616
2616
|
|
|
2617
2617
|
// src/core/utils/building/find-entrypoints.ts
|
|
2618
|
+
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
2618
2619
|
async function findEntrypoints(config) {
|
|
2619
2620
|
const relativePaths = await (0, import_fast_glob2.default)(Object.keys(PATH_GLOB_TO_TYPE_MAP), {
|
|
2620
2621
|
cwd: config.entrypointsDir
|
|
@@ -2629,7 +2630,12 @@ async function findEntrypoints(config) {
|
|
|
2629
2630
|
);
|
|
2630
2631
|
if (matchingGlob) {
|
|
2631
2632
|
const type = PATH_GLOB_TO_TYPE_MAP[matchingGlob];
|
|
2632
|
-
results.push({
|
|
2633
|
+
results.push({
|
|
2634
|
+
name,
|
|
2635
|
+
inputPath,
|
|
2636
|
+
type,
|
|
2637
|
+
skipped: config.filterEntrypoints != null && !config.filterEntrypoints.has(name)
|
|
2638
|
+
});
|
|
2633
2639
|
}
|
|
2634
2640
|
return results;
|
|
2635
2641
|
}, []);
|
|
@@ -2681,11 +2687,19 @@ async function findEntrypoints(config) {
|
|
|
2681
2687
|
await getBackgroundEntrypoint(config, {
|
|
2682
2688
|
inputPath: VIRTUAL_NOOP_BACKGROUND_MODULE_ID,
|
|
2683
2689
|
name: "background",
|
|
2684
|
-
type: "background"
|
|
2690
|
+
type: "background",
|
|
2691
|
+
skipped: false
|
|
2685
2692
|
})
|
|
2686
2693
|
);
|
|
2687
2694
|
}
|
|
2688
2695
|
config.logger.debug("All entrypoints:", entrypoints);
|
|
2696
|
+
const skippedEntrypointNames = entrypointInfos.filter((item) => item.skipped).map((item) => item.name);
|
|
2697
|
+
if (skippedEntrypointNames.length) {
|
|
2698
|
+
config.logger.warn(
|
|
2699
|
+
`Filter excluded the following entrypoints:
|
|
2700
|
+
${skippedEntrypointNames.map((item) => `${import_picocolors2.default.dim("-")} ${import_picocolors2.default.cyan(item)}`).join("\n")}`
|
|
2701
|
+
);
|
|
2702
|
+
}
|
|
2689
2703
|
const targetEntrypoints = entrypoints.filter((entry) => {
|
|
2690
2704
|
const { include, exclude } = entry.options;
|
|
2691
2705
|
if (include?.length && exclude?.length) {
|
|
@@ -2700,6 +2714,9 @@ async function findEntrypoints(config) {
|
|
|
2700
2714
|
if (include?.length && !exclude?.length) {
|
|
2701
2715
|
return include.includes(config.browser);
|
|
2702
2716
|
}
|
|
2717
|
+
if (skippedEntrypointNames.includes(entry.name)) {
|
|
2718
|
+
return false;
|
|
2719
|
+
}
|
|
2703
2720
|
return true;
|
|
2704
2721
|
});
|
|
2705
2722
|
config.logger.debug(`${config.browser} entrypoints:`, targetEntrypoints);
|
|
@@ -2752,7 +2769,7 @@ function getHtmlBaseOptions(document) {
|
|
|
2752
2769
|
}
|
|
2753
2770
|
return options;
|
|
2754
2771
|
}
|
|
2755
|
-
async function getPopupEntrypoint(config, { inputPath, name }) {
|
|
2772
|
+
async function getPopupEntrypoint(config, { inputPath, name, skipped }) {
|
|
2756
2773
|
const content = await import_fs_extra3.default.readFile(inputPath, "utf-8");
|
|
2757
2774
|
const { document } = (0, import_linkedom.parseHTML)(content);
|
|
2758
2775
|
const options = getHtmlBaseOptions(document);
|
|
@@ -2783,10 +2800,11 @@ async function getPopupEntrypoint(config, { inputPath, name }) {
|
|
|
2783
2800
|
name: "popup",
|
|
2784
2801
|
options,
|
|
2785
2802
|
inputPath,
|
|
2786
|
-
outputDir: config.outDir
|
|
2803
|
+
outputDir: config.outDir,
|
|
2804
|
+
skipped
|
|
2787
2805
|
};
|
|
2788
2806
|
}
|
|
2789
|
-
async function getOptionsEntrypoint(config, { inputPath, name }) {
|
|
2807
|
+
async function getOptionsEntrypoint(config, { inputPath, name, skipped }) {
|
|
2790
2808
|
const content = await import_fs_extra3.default.readFile(inputPath, "utf-8");
|
|
2791
2809
|
const { document } = (0, import_linkedom.parseHTML)(content);
|
|
2792
2810
|
const options = getHtmlBaseOptions(document);
|
|
@@ -2807,10 +2825,11 @@ async function getOptionsEntrypoint(config, { inputPath, name }) {
|
|
|
2807
2825
|
name: "options",
|
|
2808
2826
|
options,
|
|
2809
2827
|
inputPath,
|
|
2810
|
-
outputDir: config.outDir
|
|
2828
|
+
outputDir: config.outDir,
|
|
2829
|
+
skipped
|
|
2811
2830
|
};
|
|
2812
2831
|
}
|
|
2813
|
-
async function getUnlistedPageEntrypoint(config, { inputPath, name }) {
|
|
2832
|
+
async function getUnlistedPageEntrypoint(config, { inputPath, name, skipped }) {
|
|
2814
2833
|
const content = await import_fs_extra3.default.readFile(inputPath, "utf-8");
|
|
2815
2834
|
const { document } = (0, import_linkedom.parseHTML)(content);
|
|
2816
2835
|
return {
|
|
@@ -2818,10 +2837,11 @@ async function getUnlistedPageEntrypoint(config, { inputPath, name }) {
|
|
|
2818
2837
|
name: getEntrypointName(config.entrypointsDir, inputPath),
|
|
2819
2838
|
inputPath,
|
|
2820
2839
|
outputDir: config.outDir,
|
|
2821
|
-
options: getHtmlBaseOptions(document)
|
|
2840
|
+
options: getHtmlBaseOptions(document),
|
|
2841
|
+
skipped
|
|
2822
2842
|
};
|
|
2823
2843
|
}
|
|
2824
|
-
async function getUnlistedScriptEntrypoint(config, { inputPath, name }) {
|
|
2844
|
+
async function getUnlistedScriptEntrypoint(config, { inputPath, name, skipped }) {
|
|
2825
2845
|
const defaultExport = await importEntrypointFile(
|
|
2826
2846
|
inputPath,
|
|
2827
2847
|
config
|
|
@@ -2838,10 +2858,11 @@ async function getUnlistedScriptEntrypoint(config, { inputPath, name }) {
|
|
|
2838
2858
|
name,
|
|
2839
2859
|
inputPath,
|
|
2840
2860
|
outputDir: config.outDir,
|
|
2841
|
-
options
|
|
2861
|
+
options,
|
|
2862
|
+
skipped
|
|
2842
2863
|
};
|
|
2843
2864
|
}
|
|
2844
|
-
async function getBackgroundEntrypoint(config, { inputPath, name }) {
|
|
2865
|
+
async function getBackgroundEntrypoint(config, { inputPath, name, skipped }) {
|
|
2845
2866
|
let options = {};
|
|
2846
2867
|
if (inputPath !== VIRTUAL_NOOP_BACKGROUND_MODULE_ID) {
|
|
2847
2868
|
const defaultExport = await importEntrypointFile(
|
|
@@ -2865,10 +2886,11 @@ async function getBackgroundEntrypoint(config, { inputPath, name }) {
|
|
|
2865
2886
|
...options,
|
|
2866
2887
|
type: resolvePerBrowserOption(options.type, config.browser),
|
|
2867
2888
|
persistent: resolvePerBrowserOption(options.persistent, config.browser)
|
|
2868
|
-
}
|
|
2889
|
+
},
|
|
2890
|
+
skipped
|
|
2869
2891
|
};
|
|
2870
2892
|
}
|
|
2871
|
-
async function getContentScriptEntrypoint(config, { inputPath, name }) {
|
|
2893
|
+
async function getContentScriptEntrypoint(config, { inputPath, name, skipped }) {
|
|
2872
2894
|
const { main: _, ...options } = await importEntrypointFile(inputPath, config);
|
|
2873
2895
|
if (options == null) {
|
|
2874
2896
|
throw Error(
|
|
@@ -2880,7 +2902,8 @@ async function getContentScriptEntrypoint(config, { inputPath, name }) {
|
|
|
2880
2902
|
name,
|
|
2881
2903
|
inputPath,
|
|
2882
2904
|
outputDir: (0, import_path2.resolve)(config.outDir, CONTENT_SCRIPT_OUT_DIR),
|
|
2883
|
-
options
|
|
2905
|
+
options,
|
|
2906
|
+
skipped
|
|
2884
2907
|
};
|
|
2885
2908
|
}
|
|
2886
2909
|
var PATH_GLOB_TO_TYPE_MAP = {
|
|
@@ -3091,8 +3114,10 @@ import "wxt/browser";
|
|
|
3091
3114
|
declare module "wxt/browser" {
|
|
3092
3115
|
export type PublicPath =
|
|
3093
3116
|
{{ union }}
|
|
3117
|
+
type HtmlPublicPath = Extract<PublicPath, \`\${string}.html\`>
|
|
3094
3118
|
export interface WxtRuntime extends Runtime.Static {
|
|
3095
3119
|
getURL(path: PublicPath): string;
|
|
3120
|
+
getURL(path: \`\${HtmlPublicPath}\${string}\`): string;
|
|
3096
3121
|
}
|
|
3097
3122
|
}
|
|
3098
3123
|
`;
|
|
@@ -3710,7 +3735,7 @@ function entrypointGroupGlobals(entrypointGroup) {
|
|
|
3710
3735
|
}
|
|
3711
3736
|
|
|
3712
3737
|
// src/core/builders/vite/index.ts
|
|
3713
|
-
async function
|
|
3738
|
+
async function createViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
3714
3739
|
const vite = await import("vite");
|
|
3715
3740
|
const getBaseConfig = async () => {
|
|
3716
3741
|
const resolvedInlineConfig = await inlineConfig.vite?.(wxtConfig.env) ?? {};
|
|
@@ -3947,6 +3972,7 @@ async function getInternalConfig(inlineConfig, command, server) {
|
|
|
3947
3972
|
srcDir,
|
|
3948
3973
|
mergedConfig.entrypointsDir ?? "entrypoints"
|
|
3949
3974
|
);
|
|
3975
|
+
const filterEntrypoints = !!mergedConfig.filterEntrypoints?.length ? new Set(mergedConfig.filterEntrypoints) : void 0;
|
|
3950
3976
|
const publicDir = import_node_path7.default.resolve(srcDir, mergedConfig.publicDir ?? "public");
|
|
3951
3977
|
const typesDir = import_node_path7.default.resolve(wxtDir, "types");
|
|
3952
3978
|
const outBaseDir = import_node_path7.default.resolve(root, mergedConfig.outDir ?? ".output");
|
|
@@ -3973,6 +3999,7 @@ async function getInternalConfig(inlineConfig, command, server) {
|
|
|
3973
3999
|
command,
|
|
3974
4000
|
debug,
|
|
3975
4001
|
entrypointsDir,
|
|
4002
|
+
filterEntrypoints,
|
|
3976
4003
|
env,
|
|
3977
4004
|
fsCache: createFsCache(wxtDir),
|
|
3978
4005
|
imports: mergedConfig.imports ?? {},
|
|
@@ -4004,7 +4031,7 @@ async function getInternalConfig(inlineConfig, command, server) {
|
|
|
4004
4031
|
},
|
|
4005
4032
|
server
|
|
4006
4033
|
};
|
|
4007
|
-
const builder = await
|
|
4034
|
+
const builder = await createViteBuilder(
|
|
4008
4035
|
inlineConfig,
|
|
4009
4036
|
userConfig,
|
|
4010
4037
|
finalConfig
|
|
@@ -4046,6 +4073,7 @@ function mergeInlineConfig(inlineConfig, userConfig) {
|
|
|
4046
4073
|
configFile: inlineConfig.configFile,
|
|
4047
4074
|
debug: inlineConfig.debug ?? userConfig.debug,
|
|
4048
4075
|
entrypointsDir: inlineConfig.entrypointsDir ?? userConfig.entrypointsDir,
|
|
4076
|
+
filterEntrypoints: inlineConfig.filterEntrypoints ?? userConfig.filterEntrypoints,
|
|
4049
4077
|
imports,
|
|
4050
4078
|
logger: inlineConfig.logger ?? userConfig.logger,
|
|
4051
4079
|
manifest,
|
|
@@ -4211,8 +4239,16 @@ async function importEntrypointFile(path10, config) {
|
|
|
4211
4239
|
const res = await jiti(path10);
|
|
4212
4240
|
return res.default;
|
|
4213
4241
|
} catch (err) {
|
|
4214
|
-
|
|
4215
|
-
|
|
4242
|
+
if (err instanceof ReferenceError) {
|
|
4243
|
+
const variableName = err.message.replace(" is not defined", "");
|
|
4244
|
+
const filePath = (0, import_node_path8.relative)(config.root, path10);
|
|
4245
|
+
throw Error(
|
|
4246
|
+
`${filePath}: Cannot use imported variable "${variableName}" outside the main function. See https://wxt.dev/guide/entrypoints.html#side-effects`,
|
|
4247
|
+
{ cause: err }
|
|
4248
|
+
);
|
|
4249
|
+
} else {
|
|
4250
|
+
throw err;
|
|
4251
|
+
}
|
|
4216
4252
|
}
|
|
4217
4253
|
}
|
|
4218
4254
|
function getEsbuildOptions(opts) {
|
|
@@ -4225,7 +4261,7 @@ function getEsbuildOptions(opts) {
|
|
|
4225
4261
|
}
|
|
4226
4262
|
|
|
4227
4263
|
// src/core/utils/building/internal-build.ts
|
|
4228
|
-
var
|
|
4264
|
+
var import_picocolors5 = __toESM(require("picocolors"), 1);
|
|
4229
4265
|
var import_fs_extra12 = __toESM(require("fs-extra"), 1);
|
|
4230
4266
|
|
|
4231
4267
|
// src/core/utils/log/printBuildSummary.ts
|
|
@@ -4233,7 +4269,7 @@ var import_path7 = require("path");
|
|
|
4233
4269
|
|
|
4234
4270
|
// src/core/utils/log/printFileList.ts
|
|
4235
4271
|
var import_node_path9 = __toESM(require("path"), 1);
|
|
4236
|
-
var
|
|
4272
|
+
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
4237
4273
|
var import_fs_extra9 = __toESM(require("fs-extra"), 1);
|
|
4238
4274
|
var import_filesize = require("filesize");
|
|
4239
4275
|
|
|
@@ -4279,25 +4315,25 @@ async function printFileList(log, header, baseDir, files) {
|
|
|
4279
4315
|
totalSize += stats.size;
|
|
4280
4316
|
const size = String((0, import_filesize.filesize)(stats.size));
|
|
4281
4317
|
return [
|
|
4282
|
-
`${
|
|
4283
|
-
|
|
4318
|
+
`${import_picocolors3.default.gray(prefix)} ${import_picocolors3.default.dim(parts[0])}${color(parts[1])}`,
|
|
4319
|
+
import_picocolors3.default.dim(size)
|
|
4284
4320
|
];
|
|
4285
4321
|
})
|
|
4286
4322
|
);
|
|
4287
|
-
fileRows.push([`${
|
|
4323
|
+
fileRows.push([`${import_picocolors3.default.cyan("\u03A3 Total size:")} ${String((0, import_filesize.filesize)(totalSize))}`]);
|
|
4288
4324
|
printTable(log, header, fileRows);
|
|
4289
4325
|
}
|
|
4290
|
-
var DEFAULT_COLOR =
|
|
4326
|
+
var DEFAULT_COLOR = import_picocolors3.default.blue;
|
|
4291
4327
|
var CHUNK_COLORS = {
|
|
4292
|
-
".js.map":
|
|
4293
|
-
".cjs.map":
|
|
4294
|
-
".mjs.map":
|
|
4295
|
-
".html":
|
|
4296
|
-
".css":
|
|
4297
|
-
".js":
|
|
4298
|
-
".cjs":
|
|
4299
|
-
".mjs":
|
|
4300
|
-
".zip":
|
|
4328
|
+
".js.map": import_picocolors3.default.gray,
|
|
4329
|
+
".cjs.map": import_picocolors3.default.gray,
|
|
4330
|
+
".mjs.map": import_picocolors3.default.gray,
|
|
4331
|
+
".html": import_picocolors3.default.green,
|
|
4332
|
+
".css": import_picocolors3.default.magenta,
|
|
4333
|
+
".js": import_picocolors3.default.cyan,
|
|
4334
|
+
".cjs": import_picocolors3.default.cyan,
|
|
4335
|
+
".mjs": import_picocolors3.default.cyan,
|
|
4336
|
+
".zip": import_picocolors3.default.yellow
|
|
4301
4337
|
};
|
|
4302
4338
|
function getChunkColor(filename) {
|
|
4303
4339
|
return Object.entries(CHUNK_COLORS).find(([key]) => filename.endsWith(key))?.[1] ?? DEFAULT_COLOR;
|
|
@@ -4334,10 +4370,10 @@ function getChunkSortWeight(filename) {
|
|
|
4334
4370
|
}
|
|
4335
4371
|
|
|
4336
4372
|
// src/core/utils/log/printHeader.ts
|
|
4337
|
-
var
|
|
4373
|
+
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
4338
4374
|
|
|
4339
4375
|
// package.json
|
|
4340
|
-
var version = "0.14.
|
|
4376
|
+
var version = "0.14.2";
|
|
4341
4377
|
|
|
4342
4378
|
// src/core/utils/log/printHeader.ts
|
|
4343
4379
|
var import_consola2 = require("consola");
|
|
@@ -4873,13 +4909,12 @@ function stripPathFromMatchPattern(pattern) {
|
|
|
4873
4909
|
}
|
|
4874
4910
|
|
|
4875
4911
|
// src/core/utils/building/rebuild.ts
|
|
4876
|
-
async function rebuild(config, entrypointGroups, existingOutput = {
|
|
4912
|
+
async function rebuild(config, allEntrypoints, entrypointGroups, existingOutput = {
|
|
4877
4913
|
steps: [],
|
|
4878
4914
|
publicAssets: []
|
|
4879
4915
|
}) {
|
|
4880
4916
|
const { default: ora } = await import("ora");
|
|
4881
4917
|
const spinner = ora(`Preparing...`).start();
|
|
4882
|
-
const allEntrypoints = await findEntrypoints(config);
|
|
4883
4918
|
await generateTypesDir(allEntrypoints, config).catch((err) => {
|
|
4884
4919
|
config.logger.warn("Failed to update .wxt directory:", err);
|
|
4885
4920
|
if (config.command === "build")
|
|
@@ -4919,7 +4954,7 @@ async function internalBuild(config) {
|
|
|
4919
4954
|
const verb = config.command === "serve" ? "Pre-rendering" : "Building";
|
|
4920
4955
|
const target = `${config.browser}-mv${config.manifestVersion}`;
|
|
4921
4956
|
config.logger.info(
|
|
4922
|
-
`${verb} ${
|
|
4957
|
+
`${verb} ${import_picocolors5.default.cyan(target)} for ${import_picocolors5.default.cyan(config.mode)} with ${import_picocolors5.default.green(
|
|
4923
4958
|
`${config.builder.name} ${config.builder.version}`
|
|
4924
4959
|
)}`
|
|
4925
4960
|
);
|
|
@@ -4929,7 +4964,7 @@ async function internalBuild(config) {
|
|
|
4929
4964
|
const entrypoints = await findEntrypoints(config);
|
|
4930
4965
|
config.logger.debug("Detected entrypoints:", entrypoints);
|
|
4931
4966
|
const groups = groupEntrypoints(entrypoints);
|
|
4932
|
-
const { output } = await rebuild(config, groups, void 0);
|
|
4967
|
+
const { output } = await rebuild(config, entrypoints, groups, void 0);
|
|
4933
4968
|
await printBuildSummary(
|
|
4934
4969
|
config.logger.success,
|
|
4935
4970
|
`Built extension in ${formatDuration(Date.now() - startTime)}`,
|
|
@@ -4940,7 +4975,7 @@ async function internalBuild(config) {
|
|
|
4940
4975
|
await combineAnalysisStats(config);
|
|
4941
4976
|
config.logger.info(
|
|
4942
4977
|
`Analysis complete:
|
|
4943
|
-
${
|
|
4978
|
+
${import_picocolors5.default.gray("\u2514\u2500")} ${import_picocolors5.default.yellow("stats.html")}`
|
|
4944
4979
|
);
|
|
4945
4980
|
}
|
|
4946
4981
|
return output;
|
|
@@ -4969,7 +5004,7 @@ var import_node_path13 = __toESM(require("path"), 1);
|
|
|
4969
5004
|
var import_fast_glob4 = __toESM(require("fast-glob"), 1);
|
|
4970
5005
|
var import_fs_extra13 = __toESM(require("fs-extra"), 1);
|
|
4971
5006
|
var import_consola3 = require("consola");
|
|
4972
|
-
var
|
|
5007
|
+
var import_picocolors6 = __toESM(require("picocolors"), 1);
|
|
4973
5008
|
async function clean(root = process.cwd()) {
|
|
4974
5009
|
import_consola3.consola.info("Cleaning Project");
|
|
4975
5010
|
const tempDirs = [
|
|
@@ -4978,7 +5013,7 @@ async function clean(root = process.cwd()) {
|
|
|
4978
5013
|
"**/.wxt",
|
|
4979
5014
|
".output/*"
|
|
4980
5015
|
];
|
|
4981
|
-
import_consola3.consola.debug("Looking for:", tempDirs.map(
|
|
5016
|
+
import_consola3.consola.debug("Looking for:", tempDirs.map(import_picocolors6.default.cyan).join(", "));
|
|
4982
5017
|
const directories = await (0, import_fast_glob4.default)(tempDirs, {
|
|
4983
5018
|
cwd: import_node_path13.default.resolve(root),
|
|
4984
5019
|
absolute: true,
|
|
@@ -4991,11 +5026,11 @@ async function clean(root = process.cwd()) {
|
|
|
4991
5026
|
}
|
|
4992
5027
|
import_consola3.consola.debug(
|
|
4993
5028
|
"Found:",
|
|
4994
|
-
directories.map((dir) =>
|
|
5029
|
+
directories.map((dir) => import_picocolors6.default.cyan(import_node_path13.default.relative(root, dir))).join(", ")
|
|
4995
5030
|
);
|
|
4996
5031
|
for (const directory of directories) {
|
|
4997
5032
|
await import_fs_extra13.default.rm(directory, { force: true, recursive: true });
|
|
4998
|
-
import_consola3.consola.debug("Deleted " +
|
|
5033
|
+
import_consola3.consola.debug("Deleted " + import_picocolors6.default.cyan(import_node_path13.default.relative(root, directory)));
|
|
4999
5034
|
}
|
|
5000
5035
|
}
|
|
5001
5036
|
|
|
@@ -5140,7 +5175,7 @@ async function createExtensionRunner(config) {
|
|
|
5140
5175
|
// src/core/create-server.ts
|
|
5141
5176
|
var import_consola4 = require("consola");
|
|
5142
5177
|
var import_async_mutex = require("async-mutex");
|
|
5143
|
-
var
|
|
5178
|
+
var import_picocolors7 = __toESM(require("picocolors"), 1);
|
|
5144
5179
|
var import_node_path17 = require("path");
|
|
5145
5180
|
async function createServer(inlineConfig) {
|
|
5146
5181
|
const port = await getPort();
|
|
@@ -5221,15 +5256,17 @@ function createFileReloader(options) {
|
|
|
5221
5256
|
if (changes.type === "no-change")
|
|
5222
5257
|
return;
|
|
5223
5258
|
config.logger.info(
|
|
5224
|
-
`Changed: ${Array.from(new Set(fileChanges.map((change) => change[1]))).map((file) =>
|
|
5259
|
+
`Changed: ${Array.from(new Set(fileChanges.map((change) => change[1]))).map((file) => import_picocolors7.default.dim((0, import_node_path17.relative)(config.root, file))).join(", ")}`
|
|
5225
5260
|
);
|
|
5226
5261
|
const rebuiltNames = changes.rebuildGroups.flat().map((entry) => {
|
|
5227
|
-
return
|
|
5262
|
+
return import_picocolors7.default.cyan(
|
|
5228
5263
|
(0, import_node_path17.relative)(config.outDir, getEntrypointOutputFile(entry, ""))
|
|
5229
5264
|
);
|
|
5230
|
-
}).join(
|
|
5265
|
+
}).join(import_picocolors7.default.dim(", "));
|
|
5266
|
+
const allEntrypoints = await findEntrypoints(config);
|
|
5231
5267
|
const { output: newOutput } = await rebuild(
|
|
5232
5268
|
config,
|
|
5269
|
+
allEntrypoints,
|
|
5233
5270
|
// TODO: this excludes new entrypoints, so they're not built until the dev command is restarted
|
|
5234
5271
|
changes.rebuildGroups,
|
|
5235
5272
|
changes.cachedOutput
|
|
@@ -5293,7 +5330,7 @@ var import_consola5 = require("consola");
|
|
|
5293
5330
|
var import_giget = require("giget");
|
|
5294
5331
|
var import_fs_extra14 = __toESM(require("fs-extra"), 1);
|
|
5295
5332
|
var import_node_path18 = __toESM(require("path"), 1);
|
|
5296
|
-
var
|
|
5333
|
+
var import_picocolors8 = __toESM(require("picocolors"), 1);
|
|
5297
5334
|
async function initialize(options) {
|
|
5298
5335
|
import_consola5.consola.info("Initalizing new project");
|
|
5299
5336
|
const templates = await listTemplates();
|
|
@@ -5322,11 +5359,11 @@ async function initialize(options) {
|
|
|
5322
5359
|
type: () => options.packageManager == null ? "select" : void 0,
|
|
5323
5360
|
message: "Package Manager",
|
|
5324
5361
|
choices: [
|
|
5325
|
-
{ title:
|
|
5326
|
-
{ title:
|
|
5327
|
-
{ title:
|
|
5362
|
+
{ title: import_picocolors8.default.red("npm"), value: "npm" },
|
|
5363
|
+
{ title: import_picocolors8.default.yellow("pnpm"), value: "pnpm" },
|
|
5364
|
+
{ title: import_picocolors8.default.cyan("yarn"), value: "yarn" },
|
|
5328
5365
|
{
|
|
5329
|
-
title: `${
|
|
5366
|
+
title: `${import_picocolors8.default.magenta("bun")}${import_picocolors8.default.gray(" (experimental)")}`,
|
|
5330
5367
|
value: "bun"
|
|
5331
5368
|
}
|
|
5332
5369
|
]
|
|
@@ -5349,8 +5386,8 @@ async function initialize(options) {
|
|
|
5349
5386
|
import_consola5.consola.log("Next steps:");
|
|
5350
5387
|
let step = 0;
|
|
5351
5388
|
if (cdPath !== "")
|
|
5352
|
-
import_consola5.consola.log(` ${++step}.`,
|
|
5353
|
-
import_consola5.consola.log(` ${++step}.`,
|
|
5389
|
+
import_consola5.consola.log(` ${++step}.`, import_picocolors8.default.cyan(`cd ${cdPath}`));
|
|
5390
|
+
import_consola5.consola.log(` ${++step}.`, import_picocolors8.default.cyan(`${input.packageManager} install`));
|
|
5354
5391
|
console.log();
|
|
5355
5392
|
}
|
|
5356
5393
|
async function listTemplates() {
|
|
@@ -5404,11 +5441,11 @@ async function cloneProject({
|
|
|
5404
5441
|
}
|
|
5405
5442
|
}
|
|
5406
5443
|
var TEMPLATE_COLORS = {
|
|
5407
|
-
vanilla:
|
|
5408
|
-
vue:
|
|
5409
|
-
react:
|
|
5410
|
-
svelte:
|
|
5411
|
-
solid:
|
|
5444
|
+
vanilla: import_picocolors8.default.blue,
|
|
5445
|
+
vue: import_picocolors8.default.green,
|
|
5446
|
+
react: import_picocolors8.default.cyan,
|
|
5447
|
+
svelte: import_picocolors8.default.red,
|
|
5448
|
+
solid: import_picocolors8.default.blue
|
|
5412
5449
|
};
|
|
5413
5450
|
var TEMPLATE_SORT_WEIGHT = {
|
|
5414
5451
|
vanilla: 0,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-
|
|
2
|
-
export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, t as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, x as WxtBuilder, y as WxtBuilderServer, a as WxtViteConfig } from './external-
|
|
1
|
+
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-QOQPHF1G.cjs';
|
|
2
|
+
export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, t as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, x as WxtBuilder, y as WxtBuilderServer, a as WxtViteConfig } from './external-QOQPHF1G.cjs';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
@@ -62,6 +62,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
62
62
|
*/
|
|
63
63
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
64
64
|
|
|
65
|
-
var version = "0.14.
|
|
65
|
+
var version = "0.14.2";
|
|
66
66
|
|
|
67
67
|
export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-
|
|
2
|
-
export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, t as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, x as WxtBuilder, y as WxtBuilderServer, a as WxtViteConfig } from './external-
|
|
1
|
+
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-QOQPHF1G.js';
|
|
2
|
+
export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, t as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, x as WxtBuilder, y as WxtBuilderServer, a as WxtViteConfig } from './external-QOQPHF1G.js';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
@@ -62,6 +62,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
62
62
|
*/
|
|
63
63
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
64
64
|
|
|
65
|
-
var version = "0.14.
|
|
65
|
+
var version = "0.14.2";
|
|
66
66
|
|
|
67
67
|
export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
rebuild,
|
|
16
16
|
resolvePerBrowserOption,
|
|
17
17
|
version
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-TX6NW7VP.js";
|
|
19
19
|
import "./chunk-VBXJIVYU.js";
|
|
20
20
|
|
|
21
21
|
// src/core/build.ts
|
|
@@ -288,8 +288,10 @@ function createFileReloader(options) {
|
|
|
288
288
|
relative4(config.outDir, getEntrypointOutputFile(entry, ""))
|
|
289
289
|
);
|
|
290
290
|
}).join(pc2.dim(", "));
|
|
291
|
+
const allEntrypoints = await findEntrypoints(config);
|
|
291
292
|
const { output: newOutput } = await rebuild(
|
|
292
293
|
config,
|
|
294
|
+
allEntrypoints,
|
|
293
295
|
// TODO: this excludes new entrypoints, so they're not built until the dev command is restarted
|
|
294
296
|
changes.rebuildGroups,
|
|
295
297
|
changes.cachedOutput
|
package/dist/testing.cjs
CHANGED
|
@@ -643,6 +643,7 @@ var import_minimatch = require("minimatch");
|
|
|
643
643
|
var import_linkedom2 = require("linkedom");
|
|
644
644
|
var import_json5 = __toESM(require("json5"), 1);
|
|
645
645
|
var import_fast_glob2 = __toESM(require("fast-glob"), 1);
|
|
646
|
+
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
646
647
|
var PATH_GLOB_TO_TYPE_MAP = {
|
|
647
648
|
"sandbox.html": "sandbox",
|
|
648
649
|
"sandbox/index.html": "sandbox",
|
|
@@ -718,7 +719,7 @@ function createFsCache(wxtDir) {
|
|
|
718
719
|
var import_consola = __toESM(require("consola"), 1);
|
|
719
720
|
|
|
720
721
|
// src/core/builders/vite/index.ts
|
|
721
|
-
async function
|
|
722
|
+
async function createViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
722
723
|
const vite = await import("vite");
|
|
723
724
|
const getBaseConfig = async () => {
|
|
724
725
|
const resolvedInlineConfig = await inlineConfig.vite?.(wxtConfig.env) ?? {};
|
|
@@ -955,6 +956,7 @@ async function getInternalConfig(inlineConfig, command, server) {
|
|
|
955
956
|
srcDir,
|
|
956
957
|
mergedConfig.entrypointsDir ?? "entrypoints"
|
|
957
958
|
);
|
|
959
|
+
const filterEntrypoints = !!mergedConfig.filterEntrypoints?.length ? new Set(mergedConfig.filterEntrypoints) : void 0;
|
|
958
960
|
const publicDir = import_node_path7.default.resolve(srcDir, mergedConfig.publicDir ?? "public");
|
|
959
961
|
const typesDir = import_node_path7.default.resolve(wxtDir, "types");
|
|
960
962
|
const outBaseDir = import_node_path7.default.resolve(root, mergedConfig.outDir ?? ".output");
|
|
@@ -981,6 +983,7 @@ async function getInternalConfig(inlineConfig, command, server) {
|
|
|
981
983
|
command,
|
|
982
984
|
debug,
|
|
983
985
|
entrypointsDir,
|
|
986
|
+
filterEntrypoints,
|
|
984
987
|
env,
|
|
985
988
|
fsCache: createFsCache(wxtDir),
|
|
986
989
|
imports: mergedConfig.imports ?? {},
|
|
@@ -1012,7 +1015,7 @@ async function getInternalConfig(inlineConfig, command, server) {
|
|
|
1012
1015
|
},
|
|
1013
1016
|
server
|
|
1014
1017
|
};
|
|
1015
|
-
const builder = await
|
|
1018
|
+
const builder = await createViteBuilder(
|
|
1016
1019
|
inlineConfig,
|
|
1017
1020
|
userConfig,
|
|
1018
1021
|
finalConfig
|
|
@@ -1054,6 +1057,7 @@ function mergeInlineConfig(inlineConfig, userConfig) {
|
|
|
1054
1057
|
configFile: inlineConfig.configFile,
|
|
1055
1058
|
debug: inlineConfig.debug ?? userConfig.debug,
|
|
1056
1059
|
entrypointsDir: inlineConfig.entrypointsDir ?? userConfig.entrypointsDir,
|
|
1060
|
+
filterEntrypoints: inlineConfig.filterEntrypoints ?? userConfig.filterEntrypoints,
|
|
1057
1061
|
imports,
|
|
1058
1062
|
logger: inlineConfig.logger ?? userConfig.logger,
|
|
1059
1063
|
manifest,
|
|
@@ -1110,29 +1114,29 @@ var import_esbuild = require("esbuild");
|
|
|
1110
1114
|
var import_node_url = require("url");
|
|
1111
1115
|
|
|
1112
1116
|
// src/core/utils/building/internal-build.ts
|
|
1113
|
-
var
|
|
1117
|
+
var import_picocolors5 = __toESM(require("picocolors"), 1);
|
|
1114
1118
|
var import_fs_extra12 = __toESM(require("fs-extra"), 1);
|
|
1115
1119
|
|
|
1116
1120
|
// src/core/utils/log/printFileList.ts
|
|
1117
1121
|
var import_node_path9 = __toESM(require("path"), 1);
|
|
1118
|
-
var
|
|
1122
|
+
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
1119
1123
|
var import_fs_extra9 = __toESM(require("fs-extra"), 1);
|
|
1120
1124
|
var import_filesize = require("filesize");
|
|
1121
|
-
var DEFAULT_COLOR =
|
|
1125
|
+
var DEFAULT_COLOR = import_picocolors3.default.blue;
|
|
1122
1126
|
var CHUNK_COLORS = {
|
|
1123
|
-
".js.map":
|
|
1124
|
-
".cjs.map":
|
|
1125
|
-
".mjs.map":
|
|
1126
|
-
".html":
|
|
1127
|
-
".css":
|
|
1128
|
-
".js":
|
|
1129
|
-
".cjs":
|
|
1130
|
-
".mjs":
|
|
1131
|
-
".zip":
|
|
1127
|
+
".js.map": import_picocolors3.default.gray,
|
|
1128
|
+
".cjs.map": import_picocolors3.default.gray,
|
|
1129
|
+
".mjs.map": import_picocolors3.default.gray,
|
|
1130
|
+
".html": import_picocolors3.default.green,
|
|
1131
|
+
".css": import_picocolors3.default.magenta,
|
|
1132
|
+
".js": import_picocolors3.default.cyan,
|
|
1133
|
+
".cjs": import_picocolors3.default.cyan,
|
|
1134
|
+
".mjs": import_picocolors3.default.cyan,
|
|
1135
|
+
".zip": import_picocolors3.default.yellow
|
|
1132
1136
|
};
|
|
1133
1137
|
|
|
1134
1138
|
// src/core/utils/log/printHeader.ts
|
|
1135
|
-
var
|
|
1139
|
+
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
1136
1140
|
var import_consola2 = require("consola");
|
|
1137
1141
|
|
|
1138
1142
|
// src/core/utils/building/internal-build.ts
|
package/dist/testing.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { FakeBrowser, fakeBrowser } from '@webext-core/fake-browser';
|
|
2
2
|
import * as vite from 'vite';
|
|
3
|
-
import { I as InlineConfig } from './external-
|
|
3
|
+
import { I as InlineConfig } from './external-QOQPHF1G.cjs';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
6
6
|
import 'consola';
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { FakeBrowser, fakeBrowser } from '@webext-core/fake-browser';
|
|
2
2
|
import * as vite from 'vite';
|
|
3
|
-
import { I as InlineConfig } from './external-
|
|
3
|
+
import { I as InlineConfig } from './external-QOQPHF1G.js';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
6
6
|
import 'consola';
|
package/dist/testing.js
CHANGED