@sveltejs/vite-plugin-svelte 1.0.0-next.42 → 1.0.0-next.43

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.cjs CHANGED
@@ -294,8 +294,9 @@ function toSafe(base64) {
294
294
  }
295
295
 
296
296
  // src/utils/compile.ts
297
+ var scriptLangRE = /<script [^>]*lang=["']?([^"' >]+)["']?[^>]*>/;
297
298
  var _createCompileSvelte = (makeHot) => async function compileSvelte2(svelteRequest, code, options) {
298
- var _a, _b;
299
+ var _a, _b, _c;
299
300
  const { filename, normalizedFilename, cssId, ssr } = svelteRequest;
300
301
  const { emitCss = true } = options;
301
302
  const dependencies = [];
@@ -358,6 +359,7 @@ import ${JSON.stringify(cssId)};
358
359
  return {
359
360
  filename,
360
361
  normalizedFilename,
362
+ lang: ((_c = code.match(scriptLangRE)) == null ? void 0 : _c[1]) || "js",
361
363
  compiled,
362
364
  ssr,
363
365
  dependencies
@@ -1071,6 +1073,7 @@ function validateSourceMapOutputWrapper(group, i) {
1071
1073
  }
1072
1074
 
1073
1075
  // src/utils/options.ts
1076
+ var import_deepmerge = __toESM(require("deepmerge"), 1);
1074
1077
  var knownOptions = /* @__PURE__ */ new Set([
1075
1078
  "configFile",
1076
1079
  "include",
@@ -1083,7 +1086,8 @@ var knownOptions = /* @__PURE__ */ new Set([
1083
1086
  "hot",
1084
1087
  "ignorePluginPreprocessors",
1085
1088
  "disableDependencyReinclusion",
1086
- "experimental"
1089
+ "experimental",
1090
+ "kit"
1087
1091
  ]);
1088
1092
  function validateInlineOptions(inlineOptions) {
1089
1093
  const invalidKeys = Object.keys(inlineOptions || {}).filter((key) => !knownOptions.has(key));
@@ -1103,19 +1107,27 @@ async function preResolveOptions(inlineOptions = {}, viteUserConfig, viteEnv) {
1103
1107
  }
1104
1108
  };
1105
1109
  const svelteConfig = await loadSvelteConfig(viteConfigWithResolvedRoot, inlineOptions);
1106
- const merged = __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, defaultOptions), svelteConfig), inlineOptions), {
1107
- compilerOptions: __spreadValues(__spreadValues(__spreadValues({}, defaultOptions == null ? void 0 : defaultOptions.compilerOptions), svelteConfig == null ? void 0 : svelteConfig.compilerOptions), inlineOptions == null ? void 0 : inlineOptions.compilerOptions),
1108
- experimental: __spreadValues(__spreadValues(__spreadValues({}, defaultOptions == null ? void 0 : defaultOptions.experimental), svelteConfig == null ? void 0 : svelteConfig.experimental), inlineOptions == null ? void 0 : inlineOptions.experimental),
1110
+ const extraOptions = {
1109
1111
  root: viteConfigWithResolvedRoot.root,
1110
1112
  isBuild: viteEnv.command === "build",
1111
1113
  isServe: viteEnv.command === "serve",
1112
1114
  isDebug: process.env.DEBUG != null
1113
- });
1115
+ };
1116
+ const merged = mergeConfigs(defaultOptions, svelteConfig, inlineOptions, extraOptions);
1114
1117
  if (svelteConfig == null ? void 0 : svelteConfig.configFile) {
1115
1118
  merged.configFile = svelteConfig.configFile;
1116
1119
  }
1117
1120
  return merged;
1118
1121
  }
1122
+ function mergeConfigs(...configs) {
1123
+ let result = {};
1124
+ for (const config of configs.filter(Boolean)) {
1125
+ result = (0, import_deepmerge.default)(result, config, {
1126
+ arrayMerge: (target, source) => source ?? target
1127
+ });
1128
+ }
1129
+ return result;
1130
+ }
1119
1131
  function resolveOptions(preResolveOptions2, viteConfig) {
1120
1132
  const defaultOptions = {
1121
1133
  hot: viteConfig.isProduction ? false : { injectCss: !preResolveOptions2.emitCss },
@@ -1124,11 +1136,11 @@ function resolveOptions(preResolveOptions2, viteConfig) {
1124
1136
  dev: !viteConfig.isProduction
1125
1137
  }
1126
1138
  };
1127
- const merged = __spreadProps(__spreadValues(__spreadValues({}, defaultOptions), preResolveOptions2), {
1128
- compilerOptions: __spreadValues(__spreadValues({}, defaultOptions.compilerOptions), preResolveOptions2.compilerOptions),
1139
+ const extraOptions = {
1129
1140
  root: viteConfig.root,
1130
1141
  isProduction: viteConfig.isProduction
1131
- });
1142
+ };
1143
+ const merged = mergeConfigs(defaultOptions, preResolveOptions2, extraOptions);
1132
1144
  addExtraPreprocessors(merged, viteConfig);
1133
1145
  enforceOptionsForHmr(merged);
1134
1146
  enforceOptionsForProduction(merged);
@@ -1181,6 +1193,7 @@ function resolveViteRoot(viteConfig) {
1181
1193
  return (0, import_vite3.normalizePath)(viteConfig.root ? import_path4.default.resolve(viteConfig.root) : process.cwd());
1182
1194
  }
1183
1195
  function buildExtraViteConfig(options, config) {
1196
+ var _a;
1184
1197
  const svelteDeps = findRootSvelteDependencies(options.root);
1185
1198
  const extraViteConfig = {
1186
1199
  resolve: {
@@ -1191,7 +1204,7 @@ function buildExtraViteConfig(options, config) {
1191
1204
  if (options.isServe) {
1192
1205
  extraViteConfig.optimizeDeps = buildOptimizeDepsForSvelte(svelteDeps, options, config.optimizeDeps);
1193
1206
  }
1194
- if (options.experimental.prebundleSvelteLibraries) {
1207
+ if ((_a = options.experimental) == null ? void 0 : _a.prebundleSvelteLibraries) {
1195
1208
  extraViteConfig.optimizeDeps = __spreadProps(__spreadValues({}, extraViteConfig.optimizeDeps), {
1196
1209
  extensions: options.extensions ?? [".svelte"],
1197
1210
  esbuildOptions: {
@@ -1204,15 +1217,16 @@ function buildExtraViteConfig(options, config) {
1204
1217
  return extraViteConfig;
1205
1218
  }
1206
1219
  function buildOptimizeDepsForSvelte(svelteDeps, options, optimizeDeps) {
1220
+ var _a;
1207
1221
  const include = [];
1208
1222
  const exclude = ["svelte-hmr"];
1209
1223
  const isIncluded = (dep) => {
1210
- var _a;
1211
- return include.includes(dep) || ((_a = optimizeDeps == null ? void 0 : optimizeDeps.include) == null ? void 0 : _a.includes(dep));
1224
+ var _a2;
1225
+ return include.includes(dep) || ((_a2 = optimizeDeps == null ? void 0 : optimizeDeps.include) == null ? void 0 : _a2.includes(dep));
1212
1226
  };
1213
1227
  const isExcluded = (dep) => {
1214
- var _a;
1215
- return exclude.includes(dep) || ((_a = optimizeDeps == null ? void 0 : optimizeDeps.exclude) == null ? void 0 : _a.some((id) => dep === id || id.startsWith(`${dep}/`)));
1228
+ var _a2;
1229
+ return exclude.includes(dep) || ((_a2 = optimizeDeps == null ? void 0 : optimizeDeps.exclude) == null ? void 0 : _a2.some((id) => dep === id || id.startsWith(`${dep}/`)));
1216
1230
  };
1217
1231
  if (!isExcluded("svelte")) {
1218
1232
  const svelteImportsToInclude = SVELTE_IMPORTS.filter((x) => x !== "svelte/ssr");
@@ -1221,7 +1235,7 @@ function buildOptimizeDepsForSvelte(svelteDeps, options, optimizeDeps) {
1221
1235
  } else {
1222
1236
  log.debug('"svelte" is excluded in optimizeDeps.exclude, skipped adding it to include.');
1223
1237
  }
1224
- if (options.experimental.prebundleSvelteLibraries) {
1238
+ if ((_a = options.experimental) == null ? void 0 : _a.prebundleSvelteLibraries) {
1225
1239
  return { include, exclude };
1226
1240
  }
1227
1241
  svelteDeps = svelteDeps.filter((dep) => dep.type === "component-library");
@@ -1400,27 +1414,29 @@ function setupWatchers(options, cache, requestParser) {
1400
1414
  server.restart();
1401
1415
  }
1402
1416
  };
1403
- const possibleSvelteConfigs = knownSvelteConfigNames.map((cfg) => import_path5.default.join(root, cfg));
1404
- const restartOnConfigAdd = (filename) => {
1405
- if (possibleSvelteConfigs.includes(filename)) {
1406
- triggerViteRestart(filename);
1407
- }
1408
- };
1409
- const restartOnConfigChange = (filename) => {
1410
- if (filename === svelteConfigFile) {
1411
- triggerViteRestart(filename);
1412
- }
1413
- };
1414
1417
  const listenerCollection = {
1415
1418
  add: [],
1416
1419
  change: [emitChangeEventOnDependants],
1417
1420
  unlink: [removeUnlinkedFromCache, emitChangeEventOnDependants]
1418
1421
  };
1419
- if (svelteConfigFile) {
1420
- listenerCollection.change.push(restartOnConfigChange);
1421
- listenerCollection.unlink.push(restartOnConfigChange);
1422
- } else {
1423
- listenerCollection.add.push(restartOnConfigAdd);
1422
+ if (svelteConfigFile !== false) {
1423
+ const possibleSvelteConfigs = knownSvelteConfigNames.map((cfg) => import_path5.default.join(root, cfg));
1424
+ const restartOnConfigAdd = (filename) => {
1425
+ if (possibleSvelteConfigs.includes(filename)) {
1426
+ triggerViteRestart(filename);
1427
+ }
1428
+ };
1429
+ const restartOnConfigChange = (filename) => {
1430
+ if (filename === svelteConfigFile) {
1431
+ triggerViteRestart(filename);
1432
+ }
1433
+ };
1434
+ if (svelteConfigFile) {
1435
+ listenerCollection.change.push(restartOnConfigChange);
1436
+ listenerCollection.unlink.push(restartOnConfigChange);
1437
+ } else {
1438
+ listenerCollection.add.push(restartOnConfigAdd);
1439
+ }
1424
1440
  }
1425
1441
  Object.entries(listenerCollection).forEach(([evt, listeners]) => {
1426
1442
  if (listeners.length > 0) {
@@ -1507,6 +1523,95 @@ function generateSvelteMetadata(options) {
1507
1523
  return metadata;
1508
1524
  }
1509
1525
 
1526
+ // src/ui/inspector/plugin.ts
1527
+ var import_module5 = require("module");
1528
+ var defaultInspectorOptions = {
1529
+ toggleKeyCombo: process.platform === "win32" ? "control-shift" : "meta-shift",
1530
+ holdMode: false,
1531
+ showToggleButton: "active",
1532
+ toggleButtonPos: "top-right",
1533
+ customStyles: true
1534
+ };
1535
+ function svelteInspector() {
1536
+ let root;
1537
+ let rootRequire;
1538
+ let inspectorOptions;
1539
+ let append_to;
1540
+ return {
1541
+ name: "vite-plugin-svelte:inspector",
1542
+ apply: "serve",
1543
+ enforce: "pre",
1544
+ configResolved(config) {
1545
+ var _a, _b, _c;
1546
+ const vps = config.plugins.find((p) => p.name === "vite-plugin-svelte");
1547
+ if ((_c = (_b = (_a = vps == null ? void 0 : vps.api) == null ? void 0 : _a.options) == null ? void 0 : _b.experimental) == null ? void 0 : _c.inspector) {
1548
+ inspectorOptions = __spreadValues(__spreadValues({}, defaultInspectorOptions), vps.api.options.experimental.inspector);
1549
+ }
1550
+ if (!vps || !inspectorOptions) {
1551
+ this.resolveId = this.load = this.transformIndexHtml = this.transform = () => {
1552
+ };
1553
+ } else {
1554
+ root = config.root || process.cwd();
1555
+ rootRequire = (0, import_module5.createRequire)(root);
1556
+ if (vps.api.options.kit && !inspectorOptions.appendTo) {
1557
+ const out_dir = vps.api.options.kit.outDir || ".svelte-kit";
1558
+ inspectorOptions.appendTo = `${out_dir}/runtime/client/start.js`;
1559
+ }
1560
+ append_to = inspectorOptions.appendTo;
1561
+ }
1562
+ },
1563
+ async resolveId(importee, importer, options) {
1564
+ if (options == null ? void 0 : options.ssr) {
1565
+ return;
1566
+ }
1567
+ if (importee === "virtual:svelte-inspector-options") {
1568
+ return importee;
1569
+ }
1570
+ if (importee.startsWith("virtual:svelte-inspector:")) {
1571
+ const file = importee.replace("virtual:svelte-inspector:", "@sveltejs/vite-plugin-svelte/src/ui/inspector/");
1572
+ const path8 = rootRequire.resolve(file);
1573
+ if (path8) {
1574
+ return path8;
1575
+ } else {
1576
+ log.error.once(`failed to resolve ${file} for ${importee} from ${root}`);
1577
+ }
1578
+ }
1579
+ },
1580
+ load(id) {
1581
+ if (id === "virtual:svelte-inspector-options") {
1582
+ return `export default ${JSON.stringify(inspectorOptions ?? {})}`;
1583
+ }
1584
+ },
1585
+ transform(code, id, options) {
1586
+ if ((options == null ? void 0 : options.ssr) || !append_to) {
1587
+ return;
1588
+ }
1589
+ if (id.endsWith(append_to)) {
1590
+ return { code: `${code}
1591
+ import 'virtual:svelte-inspector:load-inspector.ts'` };
1592
+ }
1593
+ },
1594
+ transformIndexHtml(html) {
1595
+ if (append_to) {
1596
+ return;
1597
+ }
1598
+ return {
1599
+ html,
1600
+ tags: [
1601
+ {
1602
+ tag: "script",
1603
+ injectTo: "body",
1604
+ attrs: {
1605
+ type: "module",
1606
+ src: "/@id/virtual:svelte-inspector:load-inspector.ts"
1607
+ }
1608
+ }
1609
+ ]
1610
+ };
1611
+ }
1612
+ };
1613
+ }
1614
+
1510
1615
  // src/index.ts
1511
1616
  function svelte(inlineOptions) {
1512
1617
  if (process.env.DEBUG != null) {
@@ -1519,124 +1624,138 @@ function svelte(inlineOptions) {
1519
1624
  let viteConfig;
1520
1625
  let compileSvelte2;
1521
1626
  let resolvedSvelteSSR;
1522
- return {
1523
- name: "vite-plugin-svelte",
1524
- enforce: "pre",
1525
- async config(config, configEnv) {
1526
- if (process.env.DEBUG) {
1527
- log.setLevel("debug");
1528
- } else if (config.logLevel) {
1529
- log.setLevel(config.logLevel);
1530
- }
1531
- options = await preResolveOptions(inlineOptions, config, configEnv);
1532
- const extraViteConfig = buildExtraViteConfig(options, config);
1533
- log.debug("additional vite config", extraViteConfig);
1534
- return extraViteConfig;
1535
- },
1536
- async configResolved(config) {
1537
- options = resolveOptions(options, config);
1538
- patchResolvedViteConfig(config, options);
1539
- requestParser = buildIdParser(options);
1540
- compileSvelte2 = createCompileSvelte(options);
1541
- viteConfig = config;
1542
- log.debug("resolved options", options);
1543
- },
1544
- async buildStart() {
1545
- if (!options.experimental.prebundleSvelteLibraries)
1546
- return;
1547
- const isSvelteMetadataChanged = await saveSvelteMetadata(viteConfig.cacheDir, options);
1548
- if (isSvelteMetadataChanged) {
1549
- viteConfig.server.force = true;
1550
- }
1551
- },
1552
- configureServer(server) {
1553
- options.server = server;
1554
- setupWatchers(options, cache, requestParser);
1555
- },
1556
- load(id, opts) {
1557
- const ssr = opts === true || (opts == null ? void 0 : opts.ssr);
1558
- const svelteRequest = requestParser(id, !!ssr);
1559
- if (svelteRequest) {
1560
- const { filename, query } = svelteRequest;
1561
- if (query.svelte && query.type === "style") {
1562
- const css = cache.getCSS(svelteRequest);
1563
- if (css) {
1564
- log.debug(`load returns css for ${filename}`);
1565
- return css;
1627
+ const api = {};
1628
+ const plugins = [
1629
+ {
1630
+ name: "vite-plugin-svelte",
1631
+ enforce: "pre",
1632
+ api,
1633
+ async config(config, configEnv) {
1634
+ if (process.env.DEBUG) {
1635
+ log.setLevel("debug");
1636
+ } else if (config.logLevel) {
1637
+ log.setLevel(config.logLevel);
1638
+ }
1639
+ options = await preResolveOptions(inlineOptions, config, configEnv);
1640
+ const extraViteConfig = buildExtraViteConfig(options, config);
1641
+ log.debug("additional vite config", extraViteConfig);
1642
+ return extraViteConfig;
1643
+ },
1644
+ async configResolved(config) {
1645
+ options = resolveOptions(options, config);
1646
+ patchResolvedViteConfig(config, options);
1647
+ requestParser = buildIdParser(options);
1648
+ compileSvelte2 = createCompileSvelte(options);
1649
+ viteConfig = config;
1650
+ api.options = options;
1651
+ log.debug("resolved options", options);
1652
+ },
1653
+ async buildStart() {
1654
+ var _a;
1655
+ if (!((_a = options.experimental) == null ? void 0 : _a.prebundleSvelteLibraries))
1656
+ return;
1657
+ const isSvelteMetadataChanged = await saveSvelteMetadata(viteConfig.cacheDir, options);
1658
+ if (isSvelteMetadataChanged) {
1659
+ viteConfig.server.force = true;
1660
+ }
1661
+ },
1662
+ configureServer(server) {
1663
+ options.server = server;
1664
+ setupWatchers(options, cache, requestParser);
1665
+ },
1666
+ load(id, opts) {
1667
+ const ssr = opts === true || (opts == null ? void 0 : opts.ssr);
1668
+ const svelteRequest = requestParser(id, !!ssr);
1669
+ if (svelteRequest) {
1670
+ const { filename, query } = svelteRequest;
1671
+ if (query.svelte && query.type === "style") {
1672
+ const css = cache.getCSS(svelteRequest);
1673
+ if (css) {
1674
+ log.debug(`load returns css for ${filename}`);
1675
+ return css;
1676
+ }
1677
+ }
1678
+ if (viteConfig.assetsInclude(filename)) {
1679
+ log.debug(`load returns raw content for ${filename}`);
1680
+ return import_fs6.default.readFileSync(filename, "utf-8");
1566
1681
  }
1567
1682
  }
1568
- if (viteConfig.assetsInclude(filename)) {
1569
- log.debug(`load returns raw content for ${filename}`);
1570
- return import_fs6.default.readFileSync(filename, "utf-8");
1683
+ },
1684
+ async resolveId(importee, importer, opts) {
1685
+ const ssr = !!(opts == null ? void 0 : opts.ssr);
1686
+ const svelteRequest = requestParser(importee, ssr);
1687
+ if (svelteRequest == null ? void 0 : svelteRequest.query.svelte) {
1688
+ if (svelteRequest.query.type === "style") {
1689
+ log.debug(`resolveId resolved virtual css module ${svelteRequest.cssId}`);
1690
+ return svelteRequest.cssId;
1691
+ }
1692
+ log.debug(`resolveId resolved ${importee}`);
1693
+ return importee;
1571
1694
  }
1572
- }
1573
- },
1574
- async resolveId(importee, importer, opts) {
1575
- const ssr = !!(opts == null ? void 0 : opts.ssr);
1576
- const svelteRequest = requestParser(importee, ssr);
1577
- if (svelteRequest == null ? void 0 : svelteRequest.query.svelte) {
1578
- if (svelteRequest.query.type === "style") {
1579
- log.debug(`resolveId resolved virtual css module ${svelteRequest.cssId}`);
1580
- return svelteRequest.cssId;
1695
+ if (ssr && importee === "svelte") {
1696
+ if (!resolvedSvelteSSR) {
1697
+ resolvedSvelteSSR = this.resolve("svelte/ssr", void 0, { skipSelf: true }).then((svelteSSR) => {
1698
+ log.debug("resolved svelte to svelte/ssr");
1699
+ return svelteSSR;
1700
+ }, (err) => {
1701
+ log.debug("failed to resolve svelte to svelte/ssr. Update svelte to a version that exports it", err);
1702
+ return null;
1703
+ });
1704
+ }
1705
+ return resolvedSvelteSSR;
1581
1706
  }
1582
- log.debug(`resolveId resolved ${importee}`);
1583
- return importee;
1584
- }
1585
- if (ssr && importee === "svelte") {
1586
- if (!resolvedSvelteSSR) {
1587
- resolvedSvelteSSR = this.resolve("svelte/ssr", void 0, { skipSelf: true }).then((svelteSSR) => {
1588
- log.debug("resolved svelte to svelte/ssr");
1589
- return svelteSSR;
1590
- }, (err) => {
1591
- log.debug("failed to resolve svelte to svelte/ssr. Update svelte to a version that exports it", err);
1592
- return null;
1593
- });
1707
+ try {
1708
+ const resolved = resolveViaPackageJsonSvelte(importee, importer, cache);
1709
+ if (resolved) {
1710
+ log.debug(`resolveId resolved ${resolved} via package.json svelte field of ${importee}`);
1711
+ return resolved;
1712
+ }
1713
+ } catch (e) {
1714
+ log.debug.once(`error trying to resolve ${importee} from ${importer} via package.json svelte field `, e);
1594
1715
  }
1595
- return resolvedSvelteSSR;
1596
- }
1597
- try {
1598
- const resolved = resolveViaPackageJsonSvelte(importee, importer, cache);
1599
- if (resolved) {
1600
- log.debug(`resolveId resolved ${resolved} via package.json svelte field of ${importee}`);
1601
- return resolved;
1716
+ },
1717
+ async transform(code, id, opts) {
1718
+ var _a;
1719
+ const ssr = !!(opts == null ? void 0 : opts.ssr);
1720
+ const svelteRequest = requestParser(id, ssr);
1721
+ if (!svelteRequest || svelteRequest.query.svelte) {
1722
+ return;
1602
1723
  }
1603
- } catch (e) {
1604
- log.debug.once(`error trying to resolve ${importee} from ${importer} via package.json svelte field `, e);
1605
- }
1606
- },
1607
- async transform(code, id, opts) {
1608
- var _a;
1609
- const ssr = !!(opts == null ? void 0 : opts.ssr);
1610
- const svelteRequest = requestParser(id, ssr);
1611
- if (!svelteRequest || svelteRequest.query.svelte) {
1612
- return;
1613
- }
1614
- let compileData;
1615
- try {
1616
- compileData = await compileSvelte2(svelteRequest, code, options);
1617
- } catch (e) {
1618
- throw toRollupError(e, options);
1619
- }
1620
- logCompilerWarnings(compileData.compiled.warnings, options);
1621
- cache.update(compileData);
1622
- if (((_a = compileData.dependencies) == null ? void 0 : _a.length) && options.server) {
1623
- compileData.dependencies.forEach((d) => {
1624
- ensureWatchedFile(options.server.watcher, d, options.root);
1724
+ let compileData;
1725
+ try {
1726
+ compileData = await compileSvelte2(svelteRequest, code, options);
1727
+ } catch (e) {
1728
+ throw toRollupError(e, options);
1729
+ }
1730
+ logCompilerWarnings(compileData.compiled.warnings, options);
1731
+ cache.update(compileData);
1732
+ if (((_a = compileData.dependencies) == null ? void 0 : _a.length) && options.server) {
1733
+ compileData.dependencies.forEach((d) => {
1734
+ ensureWatchedFile(options.server.watcher, d, options.root);
1735
+ });
1736
+ }
1737
+ log.debug(`transform returns compiled js for ${svelteRequest.filename}`);
1738
+ return __spreadProps(__spreadValues({}, compileData.compiled.js), {
1739
+ meta: {
1740
+ vite: {
1741
+ lang: compileData.lang
1742
+ }
1743
+ }
1625
1744
  });
1626
- }
1627
- log.debug(`transform returns compiled js for ${svelteRequest.filename}`);
1628
- return compileData.compiled.js;
1629
- },
1630
- handleHotUpdate(ctx) {
1631
- if (!options.hot || !options.emitCss) {
1632
- return;
1633
- }
1634
- const svelteRequest = requestParser(ctx.file, false, ctx.timestamp);
1635
- if (svelteRequest) {
1636
- return handleHotUpdate(compileSvelte2, ctx, svelteRequest, cache, options);
1745
+ },
1746
+ handleHotUpdate(ctx) {
1747
+ if (!options.hot || !options.emitCss) {
1748
+ return;
1749
+ }
1750
+ const svelteRequest = requestParser(ctx.file, false, ctx.timestamp);
1751
+ if (svelteRequest) {
1752
+ return handleHotUpdate(compileSvelte2, ctx, svelteRequest, cache, options);
1753
+ }
1637
1754
  }
1638
1755
  }
1639
- };
1756
+ ];
1757
+ plugins.push(svelteInspector());
1758
+ return plugins.filter(Boolean);
1640
1759
  }
1641
1760
  // Annotate the CommonJS export names for ESM import in node:
1642
1761
  0 && (module.exports = {