wxt 0.1.1-alpha3 → 0.1.1-alpha4

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
@@ -232,7 +232,7 @@ interface ExtensionRunnerConfig {
232
232
 
233
233
  type EntrypointGroup = Entrypoint | Entrypoint[];
234
234
 
235
- var version = "0.1.1-alpha3";
235
+ var version = "0.1.1-alpha4";
236
236
 
237
237
  declare function defineConfig(config: UserConfig): UserConfig;
238
238
 
package/dist/index.js CHANGED
@@ -534,7 +534,7 @@ function findEffectedSteps(changedFile, currentOutput) {
534
534
 
535
535
  // src/index.ts
536
536
  import { Mutex } from "async-mutex";
537
- import { consola as consola3 } from "consola";
537
+ import { consola as consola2 } from "consola";
538
538
  import { relative as relative6 } from "node:path";
539
539
 
540
540
  // src/core/build/buildEntrypoints.ts
@@ -676,47 +676,47 @@ import { parseHTML as parseHTML2 } from "linkedom";
676
676
  import JSON5 from "json5";
677
677
 
678
678
  // src/core/utils/importTsFile.ts
679
- import { consola as consola2 } from "consola";
680
- import transform from "jiti/dist/babel";
679
+ import createJITI from "jiti";
681
680
  import { createUnimport as createUnimport2 } from "unimport";
682
681
  import fs6 from "fs-extra";
683
- import { loadConfig as loadConfig2 } from "c12";
684
682
  import { resolve as resolve8 } from "path";
683
+ import transform from "jiti/dist/babel";
685
684
  async function importTsFile(path5, config) {
686
- const options = getUnimportOptions(config);
687
- const unimport2 = createUnimport2(options);
688
- await unimport2.scanImportsFromDir(void 0, { cwd: config.srcDir });
685
+ config.logger.log("Loading file metadata:", path5);
686
+ const unimport2 = createUnimport2({
687
+ ...getUnimportOptions(config),
688
+ // Only allow specific imports, not all from the project
689
+ imports: [{ name: "*", as: "browser", from: "webextension-polyfill" }],
690
+ dirs: []
691
+ });
692
+ await unimport2.init();
689
693
  const text = await fs6.readFile(path5, "utf-8");
690
- const res = await unimport2.injectImports(text, path5);
691
- const transformedText = res.code;
694
+ const textNoImports = text.replace(/import.*[\n;]/gm, "");
695
+ const { code } = await unimport2.injectImports(textNoImports);
696
+ config.logger.log(
697
+ ["Text:", text, "No imports:", textNoImports, "Code:", code].join("\n")
698
+ );
699
+ const jiti = createJITI(__filename, {
700
+ cache: false,
701
+ esmResolve: true,
702
+ interopDefault: true,
703
+ alias: {
704
+ "webextension-polyfill": resolve8(
705
+ config.root,
706
+ "node_modules/wxt/dist/virtual-modules/fake-browser.js"
707
+ )
708
+ },
709
+ transform(opts) {
710
+ if (opts.filename === path5)
711
+ return transform({ ...opts, source: code });
712
+ else
713
+ return transform(opts);
714
+ }
715
+ });
692
716
  try {
693
- const loaded = await loadConfig2({
694
- configFile: path5,
695
- rcFile: false,
696
- jitiOptions: {
697
- cache: false,
698
- // esmResolve: true,
699
- // interopDefault: true,
700
- alias: {
701
- "webextension-polyfill": resolve8(
702
- config.root,
703
- "node_modules/wxt/dist/virtual-modules/fake-browser.js"
704
- )
705
- },
706
- transform(opts) {
707
- if (opts.filename === path5)
708
- opts.source = transformedText;
709
- opts.source = opts.source.replace(
710
- /^import.*['"].*\.css['"];?$/gm,
711
- ""
712
- );
713
- return transform(opts);
714
- }
715
- }
716
- });
717
- return loaded.config;
717
+ return await jiti(path5);
718
718
  } catch (err) {
719
- consola2.error(`Failed to import file: ${path5}`);
719
+ config.logger.error(err);
720
720
  throw err;
721
721
  }
722
722
  }
@@ -1691,7 +1691,7 @@ function reloadHtmlPages(groups, server, config) {
1691
1691
  }
1692
1692
 
1693
1693
  // package.json
1694
- var version2 = "0.1.1-alpha3";
1694
+ var version2 = "0.1.1-alpha4";
1695
1695
 
1696
1696
  // src/core/utils/defineConfig.ts
1697
1697
  function defineConfig(config) {
@@ -1734,7 +1734,7 @@ async function createServer2(config) {
1734
1734
  const changes = detectDevChanges(fileChanges, server.currentOutput);
1735
1735
  if (changes.type === "no-change")
1736
1736
  return;
1737
- consola3.info(
1737
+ consola2.info(
1738
1738
  `Changed: ${Array.from(new Set(fileChanges.map((change) => change[1]))).map((file) => pc3.dim(relative6(internalConfig.root, file))).join(", ")}`
1739
1739
  );
1740
1740
  const rebuiltNames = changes.rebuildGroups.flat().map((entry) => {
@@ -1762,7 +1762,7 @@ async function createServer2(config) {
1762
1762
  reloadContentScripts(changes.changedSteps, internalConfig, server);
1763
1763
  break;
1764
1764
  }
1765
- consola3.success(`Reloaded: ${rebuiltNames}`);
1765
+ consola2.success(`Reloaded: ${rebuiltNames}`);
1766
1766
  });
1767
1767
  });
1768
1768
  return server;