@sveltejs/vite-plugin-svelte 1.0.0-next.35 → 1.0.0-next.36
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 +29 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -11
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +1 -1
- package/src/utils/compile.ts +7 -1
- package/src/utils/error.ts +9 -6
- package/src/utils/esbuild.ts +7 -2
- package/src/utils/log.ts +4 -1
- package/src/utils/options.ts +3 -1
package/dist/index.cjs
CHANGED
|
@@ -49,7 +49,7 @@ __export(src_exports, {
|
|
|
49
49
|
svelte: () => svelte
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
// ../../node_modules/.pnpm/tsup@5.11.11_typescript@4.5.
|
|
52
|
+
// ../../node_modules/.pnpm/tsup@5.11.11_typescript@4.5.5/node_modules/tsup/assets/cjs_shims.js
|
|
53
53
|
var getImportMetaUrl = () => typeof document === "undefined" ? new URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
54
54
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
55
55
|
|
|
@@ -192,7 +192,10 @@ function buildExtendedLogMessage(w) {
|
|
|
192
192
|
parts.push(":", w.start.line, ":", w.start.column);
|
|
193
193
|
}
|
|
194
194
|
if (w.message) {
|
|
195
|
-
parts.
|
|
195
|
+
if (parts.length > 0) {
|
|
196
|
+
parts.push(" ");
|
|
197
|
+
}
|
|
198
|
+
parts.push(w.message);
|
|
196
199
|
}
|
|
197
200
|
return parts.join("");
|
|
198
201
|
}
|
|
@@ -320,7 +323,12 @@ var _createCompileSvelte = (makeHot) => async function compileSvelte2(svelteRequ
|
|
|
320
323
|
}
|
|
321
324
|
let preprocessed;
|
|
322
325
|
if (options.preprocess) {
|
|
323
|
-
|
|
326
|
+
try {
|
|
327
|
+
preprocessed = await (0, import_compiler.preprocess)(code, options.preprocess, { filename });
|
|
328
|
+
} catch (e) {
|
|
329
|
+
e.message = `Error while preprocessing ${filename}${e.message ? ` - ${e.message}` : ""}`;
|
|
330
|
+
throw e;
|
|
331
|
+
}
|
|
324
332
|
if (preprocessed.dependencies)
|
|
325
333
|
dependencies.push(...preprocessed.dependencies);
|
|
326
334
|
if (preprocessed.map)
|
|
@@ -717,15 +725,15 @@ var import_fs3 = require("fs");
|
|
|
717
725
|
var import_compiler2 = require("svelte/compiler");
|
|
718
726
|
|
|
719
727
|
// src/utils/error.ts
|
|
720
|
-
function toRollupError(error) {
|
|
721
|
-
const { filename, frame, start, code, name } = error;
|
|
728
|
+
function toRollupError(error, options) {
|
|
729
|
+
const { filename, frame, start, code, name, stack } = error;
|
|
722
730
|
const rollupError = {
|
|
723
731
|
name,
|
|
724
732
|
id: filename,
|
|
725
733
|
message: buildExtendedLogMessage(error),
|
|
726
734
|
frame: formatFrameForVite(frame),
|
|
727
735
|
code,
|
|
728
|
-
stack: ""
|
|
736
|
+
stack: options.isBuild || options.isDebug || !frame ? stack : ""
|
|
729
737
|
};
|
|
730
738
|
if (start) {
|
|
731
739
|
rollupError.loc = {
|
|
@@ -736,8 +744,8 @@ function toRollupError(error) {
|
|
|
736
744
|
}
|
|
737
745
|
return rollupError;
|
|
738
746
|
}
|
|
739
|
-
function toESBuildError(error) {
|
|
740
|
-
const { filename, frame, start } = error;
|
|
747
|
+
function toESBuildError(error, options) {
|
|
748
|
+
const { filename, frame, start, stack } = error;
|
|
741
749
|
const partialMessage = {
|
|
742
750
|
text: buildExtendedLogMessage(error)
|
|
743
751
|
};
|
|
@@ -749,6 +757,9 @@ function toESBuildError(error) {
|
|
|
749
757
|
lineText: lineFromFrame(start.line, frame)
|
|
750
758
|
};
|
|
751
759
|
}
|
|
760
|
+
if (options.isBuild || options.isDebug || !frame) {
|
|
761
|
+
partialMessage.detail = stack;
|
|
762
|
+
}
|
|
752
763
|
return partialMessage;
|
|
753
764
|
}
|
|
754
765
|
function lineFromFrame(lineNo, frame) {
|
|
@@ -781,7 +792,7 @@ function esbuildSveltePlugin(options) {
|
|
|
781
792
|
const contents = await compileSvelte(options, { filename, code });
|
|
782
793
|
return { contents };
|
|
783
794
|
} catch (e) {
|
|
784
|
-
return { errors: [toESBuildError(e)] };
|
|
795
|
+
return { errors: [toESBuildError(e, options)] };
|
|
785
796
|
}
|
|
786
797
|
});
|
|
787
798
|
}
|
|
@@ -814,7 +825,12 @@ async function compileSvelte(options, { filename, code }) {
|
|
|
814
825
|
});
|
|
815
826
|
let preprocessed;
|
|
816
827
|
if (options.preprocess) {
|
|
817
|
-
|
|
828
|
+
try {
|
|
829
|
+
preprocessed = await (0, import_compiler2.preprocess)(code, options.preprocess, { filename });
|
|
830
|
+
} catch (e) {
|
|
831
|
+
e.message = `Error while preprocessing ${filename}${e.message ? ` - ${e.message}` : ""}`;
|
|
832
|
+
throw e;
|
|
833
|
+
}
|
|
818
834
|
if (preprocessed.map)
|
|
819
835
|
compileOptions.sourcemap = preprocessed.map;
|
|
820
836
|
}
|
|
@@ -1097,7 +1113,8 @@ async function preResolveOptions(inlineOptions = {}, viteUserConfig, viteEnv) {
|
|
|
1097
1113
|
experimental: __spreadValues(__spreadValues(__spreadValues({}, defaultOptions == null ? void 0 : defaultOptions.experimental), svelteConfig == null ? void 0 : svelteConfig.experimental), inlineOptions == null ? void 0 : inlineOptions.experimental),
|
|
1098
1114
|
root: viteConfigWithResolvedRoot.root,
|
|
1099
1115
|
isBuild: viteEnv.command === "build",
|
|
1100
|
-
isServe: viteEnv.command === "serve"
|
|
1116
|
+
isServe: viteEnv.command === "serve",
|
|
1117
|
+
isDebug: process.env.DEBUG != null
|
|
1101
1118
|
});
|
|
1102
1119
|
if (svelteConfig == null ? void 0 : svelteConfig.configFile) {
|
|
1103
1120
|
merged.configFile = svelteConfig.configFile;
|
|
@@ -1605,7 +1622,7 @@ function svelte(inlineOptions) {
|
|
|
1605
1622
|
try {
|
|
1606
1623
|
compileData = await compileSvelte2(svelteRequest, code, options);
|
|
1607
1624
|
} catch (e) {
|
|
1608
|
-
throw toRollupError(e);
|
|
1625
|
+
throw toRollupError(e, options);
|
|
1609
1626
|
}
|
|
1610
1627
|
logCompilerWarnings(compileData.compiled.warnings, options);
|
|
1611
1628
|
cache.update(compileData);
|