wxt 0.1.2 → 0.1.3

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 CHANGED
@@ -245,7 +245,7 @@ interface ExtensionRunnerConfig {
245
245
 
246
246
  type EntrypointGroup = Entrypoint | Entrypoint[];
247
247
 
248
- var version = "0.1.2";
248
+ var version = "0.1.3";
249
249
 
250
250
  declare function defineConfig(config: UserConfig): UserConfig;
251
251
 
package/dist/index.js CHANGED
@@ -371,12 +371,6 @@ async function getInternalConfig(config, command) {
371
371
  const outBaseDir = path2.resolve(root, ".output");
372
372
  const outDir = path2.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
373
373
  const logger = config.logger ?? consola;
374
- const manifest = await (typeof config.manifest === "function" ? config.manifest({
375
- browser,
376
- command,
377
- manifestVersion,
378
- mode
379
- }) : config.manifest ?? {});
380
374
  const baseConfig = {
381
375
  root,
382
376
  outDir,
@@ -388,7 +382,6 @@ async function getInternalConfig(config, command) {
388
382
  command,
389
383
  logger,
390
384
  vite: config.vite ?? {},
391
- manifest,
392
385
  imports: config.imports ?? {},
393
386
  runnerConfig: await loadConfig({
394
387
  name: "web-ext",
@@ -421,6 +414,10 @@ async function getInternalConfig(config, command) {
421
414
  const publicDir = resolve6(srcDir, userConfig.publicDir ?? "public");
422
415
  const wxtDir = resolve6(srcDir, ".wxt");
423
416
  const typesDir = resolve6(wxtDir, "types");
417
+ const env = { mode, browser, manifestVersion, command };
418
+ const userManifest = await resolveManifestConfig(env, userConfig.manifest);
419
+ const inlineManifest = await resolveManifestConfig(env, config.manifest);
420
+ const manifest = vite2.mergeConfig(userManifest, inlineManifest);
424
421
  const finalConfig = {
425
422
  ...merged,
426
423
  srcDir,
@@ -428,7 +425,8 @@ async function getInternalConfig(config, command) {
428
425
  publicDir,
429
426
  wxtDir,
430
427
  typesDir,
431
- fsCache: createFsCache(wxtDir)
428
+ fsCache: createFsCache(wxtDir),
429
+ manifest
432
430
  };
433
431
  finalConfig.vite.root = root;
434
432
  finalConfig.vite.configFile = false;
@@ -453,6 +451,9 @@ async function getInternalConfig(config, command) {
453
451
  });
454
452
  return finalConfig;
455
453
  }
454
+ async function resolveManifestConfig(env, manifest) {
455
+ return await (typeof manifest === "function" ? manifest(env) : manifest ?? {});
456
+ }
456
457
 
457
458
  // src/index.ts
458
459
  import pc3 from "picocolors";
@@ -1015,7 +1016,20 @@ async function writeTsConfigFile(mainReference, config) {
1015
1016
  "strict": true,
1016
1017
 
1017
1018
  /* Completeness */
1018
- "skipLibCheck": true
1019
+ "skipLibCheck": true,
1020
+
1021
+ /* Aliases */
1022
+ "baseUrl": "${relative4(dir, config.root)}",
1023
+ "paths": {
1024
+ "@@": ["."],
1025
+ "@@/*": ["./*"],
1026
+ "~~": ["."],
1027
+ "~~/*": ["./*"],
1028
+ "@": ["${relative4(config.root, config.srcDir)}"],
1029
+ "@/*": ["${relative4(config.root, config.srcDir)}/*"],
1030
+ "~": ["${relative4(config.root, config.srcDir)}"],
1031
+ "~/*": ["${relative4(config.root, config.srcDir)}/*"]
1032
+ }
1019
1033
  },
1020
1034
  "include": [
1021
1035
  "${relative4(dir, config.root)}/**/*",
@@ -1403,7 +1417,7 @@ function formatDuration(duration) {
1403
1417
  }
1404
1418
 
1405
1419
  // src/core/log/printBuildSummary.ts
1406
- import path4, { extname as extname3, relative as relative5, resolve as resolve12 } from "path";
1420
+ import path4, { relative as relative5, resolve as resolve12 } from "path";
1407
1421
 
1408
1422
  // src/core/log/printTable.ts
1409
1423
  function printTable(log, rows, gap = 2) {
@@ -1440,8 +1454,8 @@ async function printBuildSummary(output, config) {
1440
1454
  ...output.steps.flatMap((step) => step.chunks),
1441
1455
  ...output.publicAssets
1442
1456
  ].sort((l, r) => {
1443
- const lWeight = CHUNK_SORT_WEIGHTS[l.fileName] ?? CHUNK_SORT_WEIGHTS[extname3(l.fileName)] ?? DEFAULT_SORT_WEIGHT;
1444
- const rWeight = CHUNK_SORT_WEIGHTS[r.fileName] ?? CHUNK_SORT_WEIGHTS[extname3(r.fileName)] ?? DEFAULT_SORT_WEIGHT;
1457
+ const lWeight = getChunkSortWeight(l.fileName);
1458
+ const rWeight = getChunkSortWeight(r.fileName);
1445
1459
  const diff = lWeight - rWeight;
1446
1460
  if (diff !== 0)
1447
1461
  return diff;
@@ -1454,9 +1468,8 @@ async function printBuildSummary(output, config) {
1454
1468
  relative5(process.cwd(), config.outDir) + path4.sep,
1455
1469
  chunk.fileName
1456
1470
  ];
1457
- const ext = extname3(chunk.fileName);
1458
1471
  const prefix = i === chunks.length - 1 ? " \u2514\u2500" : " \u251C\u2500";
1459
- const color = CHUNK_COLORS[ext] ?? DEFAULT_COLOR;
1472
+ const color = getChunkColor(chunk.fileName);
1460
1473
  const stats = await fs10.lstat(resolve12(config.outDir, chunk.fileName));
1461
1474
  totalSize += stats.size;
1462
1475
  const size = String(filesize(stats.size));
@@ -1475,15 +1488,29 @@ var DEFAULT_SORT_WEIGHT = 100;
1475
1488
  var CHUNK_SORT_WEIGHTS = {
1476
1489
  "manifest.json": 0,
1477
1490
  ".html": 1,
1491
+ ".js.map": 2,
1478
1492
  ".js": 2,
1479
1493
  ".css": 3
1480
1494
  };
1495
+ function getChunkSortWeight(filename) {
1496
+ return Object.entries(CHUNK_SORT_WEIGHTS).find(([key, value]) => {
1497
+ if (filename.endsWith(key))
1498
+ return value;
1499
+ })?.[1] ?? DEFAULT_SORT_WEIGHT;
1500
+ }
1481
1501
  var DEFAULT_COLOR = pc.blue;
1482
1502
  var CHUNK_COLORS = {
1503
+ ".js.map": pc.gray,
1483
1504
  ".html": pc.green,
1484
1505
  ".css": pc.magenta,
1485
1506
  ".js": pc.cyan
1486
1507
  };
1508
+ function getChunkColor(filename) {
1509
+ return Object.entries(CHUNK_COLORS).find(([key, value]) => {
1510
+ if (filename.endsWith(key))
1511
+ return value;
1512
+ })?.[1] ?? DEFAULT_COLOR;
1513
+ }
1487
1514
 
1488
1515
  // src/core/build.ts
1489
1516
  async function buildInternal(config) {
@@ -1709,7 +1736,7 @@ function reloadHtmlPages(groups, server, config) {
1709
1736
  }
1710
1737
 
1711
1738
  // package.json
1712
- var version2 = "0.1.2";
1739
+ var version2 = "0.1.3";
1713
1740
 
1714
1741
  // src/core/utils/defineConfig.ts
1715
1742
  function defineConfig(config) {