wxt 0.5.6 → 0.6.0-alpha1

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.cts CHANGED
@@ -134,11 +134,13 @@ interface InlineConfig {
134
134
  */
135
135
  logger?: Logger;
136
136
  /**
137
- * Custom Vite options, see <https://vitejs.dev/config/shared-options.html>.
137
+ * Return custom Vite options from a function. See
138
+ * <https://vitejs.dev/config/shared-options.html>.
138
139
  *
139
- * [`root`](#root), [`configFile`](#configfile), and [`mode`](#mode) should be set in WXT's config.
140
+ * [`root`](#root), [`configFile`](#configfile), and [`mode`](#mode) should be set in WXT's config
141
+ * instead of Vite's.
140
142
  */
141
- vite?: WxtViteConfig | ((env: ConfigEnv) => WxtViteConfig | Promise<WxtViteConfig>);
143
+ vite?: (env: ConfigEnv) => WxtViteConfig | Promise<WxtViteConfig>;
142
144
  /**
143
145
  * Customize the `manifest.json` output. Can be an object, promise, or function that returns an
144
146
  * object or promise.
@@ -478,7 +480,7 @@ type EntrypointGroup = Entrypoint | Entrypoint[];
478
480
  */
479
481
  declare function clean(root?: string): Promise<void>;
480
482
 
481
- var version = "0.5.6";
483
+ var version = "0.6.0-alpha1";
482
484
 
483
485
  declare function defineConfig(config: UserConfig): UserConfig;
484
486
 
package/dist/index.d.ts CHANGED
@@ -134,11 +134,13 @@ interface InlineConfig {
134
134
  */
135
135
  logger?: Logger;
136
136
  /**
137
- * Custom Vite options, see <https://vitejs.dev/config/shared-options.html>.
137
+ * Return custom Vite options from a function. See
138
+ * <https://vitejs.dev/config/shared-options.html>.
138
139
  *
139
- * [`root`](#root), [`configFile`](#configfile), and [`mode`](#mode) should be set in WXT's config.
140
+ * [`root`](#root), [`configFile`](#configfile), and [`mode`](#mode) should be set in WXT's config
141
+ * instead of Vite's.
140
142
  */
141
- vite?: WxtViteConfig | ((env: ConfigEnv) => WxtViteConfig | Promise<WxtViteConfig>);
143
+ vite?: (env: ConfigEnv) => WxtViteConfig | Promise<WxtViteConfig>;
142
144
  /**
143
145
  * Customize the `manifest.json` output. Can be an object, promise, or function that returns an
144
146
  * object or promise.
@@ -478,7 +480,7 @@ type EntrypointGroup = Entrypoint | Entrypoint[];
478
480
  */
479
481
  declare function clean(root?: string): Promise<void>;
480
482
 
481
- var version = "0.5.6";
483
+ var version = "0.6.0-alpha1";
482
484
 
483
485
  declare function defineConfig(config: UserConfig): UserConfig;
484
486
 
package/dist/index.js CHANGED
@@ -506,6 +506,7 @@ async function getInternalConfig(inlineConfig, command) {
506
506
  command,
507
507
  debug,
508
508
  entrypointsDir,
509
+ env,
509
510
  fsCache: createFsCache(wxtDir),
510
511
  imports: mergedConfig.imports ?? {},
511
512
  logger,
@@ -519,16 +520,12 @@ async function getInternalConfig(inlineConfig, command) {
519
520
  runnerConfig,
520
521
  srcDir,
521
522
  typesDir,
522
- vite: {},
523
+ vite: () => ({}),
523
524
  // Real value added after this object is initialized.
524
525
  wxtDir,
525
526
  zip: resolveInternalZipConfig(root, mergedConfig)
526
527
  };
527
- finalConfig.vite = await resolveInternalViteConfig(
528
- env,
529
- mergedConfig,
530
- finalConfig
531
- );
528
+ finalConfig.vite = (env2) => resolveInternalViteConfig(env2, mergedConfig, finalConfig);
532
529
  return finalConfig;
533
530
  }
534
531
  async function resolveManifestConfig(env, manifest) {
@@ -552,9 +549,9 @@ function mergeInlineConfig(inlineConfig, userConfig) {
552
549
  return vite2.mergeConfig(user, inline);
553
550
  };
554
551
  const viteConfig = async (env) => {
555
- const user = await resolveViteConfig(env, userConfig.vite);
556
- const inline = await resolveViteConfig(env, inlineConfig.vite);
557
- return vite2.mergeConfig(user, inline);
552
+ const user = await userConfig.vite?.(env);
553
+ const inline = await inlineConfig.vite?.(env);
554
+ return vite2.mergeConfig(user ?? {}, inline ?? {});
558
555
  };
559
556
  const runner = vite2.mergeConfig(
560
557
  userConfig.runner ?? {},
@@ -582,9 +579,6 @@ function mergeInlineConfig(inlineConfig, userConfig) {
582
579
  zip
583
580
  };
584
581
  }
585
- async function resolveViteConfig(env, vite6) {
586
- return await (typeof vite6 === "function" ? vite6(env) : vite6 ?? {});
587
- }
588
582
  function resolveInternalZipConfig(root, mergedConfig) {
589
583
  return {
590
584
  sourcesTemplate: "{{name}}-{{version}}-sources.zip",
@@ -606,10 +600,7 @@ function resolveInternalZipConfig(root, mergedConfig) {
606
600
  };
607
601
  }
608
602
  async function resolveInternalViteConfig(env, mergedConfig, finalConfig) {
609
- const internalVite = await resolveViteConfig(
610
- env,
611
- mergedConfig.vite
612
- );
603
+ const internalVite = await mergedConfig.vite?.(env) ?? {};
613
604
  internalVite.root = finalConfig.root;
614
605
  internalVite.configFile = false;
615
606
  internalVite.logLevel = "warn";
@@ -824,7 +815,7 @@ async function buildSingleEntrypoint(entrypoint, config) {
824
815
  }
825
816
  const entryConfig = vite3.mergeConfig(
826
817
  libMode,
827
- config.vite
818
+ await config.vite(config.env)
828
819
  );
829
820
  const result = await vite3.build(entryConfig);
830
821
  return {
@@ -858,7 +849,7 @@ async function buildMultipleEntrypoints(entrypoints, config) {
858
849
  }
859
850
  const entryConfig = vite3.mergeConfig(
860
851
  multiPage,
861
- config.vite
852
+ await config.vite(config.env)
862
853
  );
863
854
  const result = await vite3.build(entryConfig);
864
855
  return {
@@ -2161,7 +2152,7 @@ async function getServerInfo() {
2161
2152
  async function setupServer(serverInfo, config) {
2162
2153
  const runner = createWebExtRunner();
2163
2154
  const viteServer = await vite5.createServer(
2164
- vite5.mergeConfig(serverInfo, config.vite)
2155
+ vite5.mergeConfig(serverInfo, await config.vite(config.env))
2165
2156
  );
2166
2157
  const start = async () => {
2167
2158
  await viteServer.listen(server.port);
@@ -2262,7 +2253,7 @@ async function clean(root = process.cwd()) {
2262
2253
  }
2263
2254
 
2264
2255
  // package.json
2265
- var version2 = "0.5.6";
2256
+ var version2 = "0.6.0-alpha1";
2266
2257
 
2267
2258
  // src/core/utils/defineConfig.ts
2268
2259
  function defineConfig(config) {
@@ -2285,7 +2276,7 @@ async function createServer2(config) {
2285
2276
  return getInternalConfig(
2286
2277
  {
2287
2278
  ...config,
2288
- vite: serverInfo.viteServerConfig
2279
+ vite: () => serverInfo.viteServerConfig
2289
2280
  },
2290
2281
  "serve"
2291
2282
  );