@sveltejs/vite-plugin-svelte 1.0.2 → 1.0.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.js CHANGED
@@ -1237,7 +1237,7 @@ async function preResolveOptions(inlineOptions = {}, viteUserConfig, viteEnv) {
1237
1237
  }
1238
1238
  function mergeConfigs(...configs) {
1239
1239
  let result = {};
1240
- for (const config of configs.filter(Boolean)) {
1240
+ for (const config of configs.filter((x) => x != null)) {
1241
1241
  result = deepmerge(result, config, {
1242
1242
  arrayMerge: (target, source) => source ?? target
1243
1243
  });
@@ -1726,6 +1726,20 @@ import { normalizePath as normalizePath3 } from "vite";
1726
1726
  import path8 from "path";
1727
1727
  import { fileURLToPath } from "url";
1728
1728
  import fs7 from "fs";
1729
+
1730
+ // src/ui/inspector/utils.ts
1731
+ var FS_PREFIX = `/@fs/`;
1732
+ var IS_WINDOWS2 = process.platform === "win32";
1733
+ var queryRE = /\?.*$/s;
1734
+ var hashRE = /#.*$/s;
1735
+ function idToFile(id) {
1736
+ if (id.startsWith(FS_PREFIX)) {
1737
+ id = id = id.slice(IS_WINDOWS2 ? FS_PREFIX.length : FS_PREFIX.length - 1);
1738
+ }
1739
+ return id.replace(hashRE, "").replace(queryRE, "");
1740
+ }
1741
+
1742
+ // src/ui/inspector/plugin.ts
1729
1743
  var defaultInspectorOptions = {
1730
1744
  toggleKeyCombo: process.platform === "win32" ? "control-shift" : "meta-shift",
1731
1745
  holdMode: false,
@@ -1786,7 +1800,12 @@ function svelteInspector() {
1786
1800
  if (id === "virtual:svelte-inspector-options") {
1787
1801
  return `export default ${JSON.stringify(inspectorOptions ?? {})}`;
1788
1802
  } else if (id.startsWith(inspectorPath)) {
1789
- return await fs7.promises.readFile(id, "utf-8");
1803
+ const file = idToFile(id);
1804
+ if (fs7.existsSync(file)) {
1805
+ return await fs7.promises.readFile(file, "utf-8");
1806
+ } else {
1807
+ log.error(`failed to find file for svelte-inspector: ${file}, referenced by id ${id}.`);
1808
+ }
1790
1809
  }
1791
1810
  },
1792
1811
  transform(code, id, options) {