@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.js
CHANGED
|
@@ -164,7 +164,10 @@ function buildExtendedLogMessage(w) {
|
|
|
164
164
|
parts.push(":", w.start.line, ":", w.start.column);
|
|
165
165
|
}
|
|
166
166
|
if (w.message) {
|
|
167
|
-
parts.
|
|
167
|
+
if (parts.length > 0) {
|
|
168
|
+
parts.push(" ");
|
|
169
|
+
}
|
|
170
|
+
parts.push(w.message);
|
|
168
171
|
}
|
|
169
172
|
return parts.join("");
|
|
170
173
|
}
|
|
@@ -292,7 +295,12 @@ var _createCompileSvelte = (makeHot) => async function compileSvelte2(svelteRequ
|
|
|
292
295
|
}
|
|
293
296
|
let preprocessed;
|
|
294
297
|
if (options.preprocess) {
|
|
295
|
-
|
|
298
|
+
try {
|
|
299
|
+
preprocessed = await preprocess(code, options.preprocess, { filename });
|
|
300
|
+
} catch (e) {
|
|
301
|
+
e.message = `Error while preprocessing ${filename}${e.message ? ` - ${e.message}` : ""}`;
|
|
302
|
+
throw e;
|
|
303
|
+
}
|
|
296
304
|
if (preprocessed.dependencies)
|
|
297
305
|
dependencies.push(...preprocessed.dependencies);
|
|
298
306
|
if (preprocessed.map)
|
|
@@ -691,15 +699,15 @@ import { promises as fs4 } from "fs";
|
|
|
691
699
|
import { compile as compile2, preprocess as preprocess2 } from "svelte/compiler";
|
|
692
700
|
|
|
693
701
|
// src/utils/error.ts
|
|
694
|
-
function toRollupError(error) {
|
|
695
|
-
const { filename, frame, start, code, name } = error;
|
|
702
|
+
function toRollupError(error, options) {
|
|
703
|
+
const { filename, frame, start, code, name, stack } = error;
|
|
696
704
|
const rollupError = {
|
|
697
705
|
name,
|
|
698
706
|
id: filename,
|
|
699
707
|
message: buildExtendedLogMessage(error),
|
|
700
708
|
frame: formatFrameForVite(frame),
|
|
701
709
|
code,
|
|
702
|
-
stack: ""
|
|
710
|
+
stack: options.isBuild || options.isDebug || !frame ? stack : ""
|
|
703
711
|
};
|
|
704
712
|
if (start) {
|
|
705
713
|
rollupError.loc = {
|
|
@@ -710,8 +718,8 @@ function toRollupError(error) {
|
|
|
710
718
|
}
|
|
711
719
|
return rollupError;
|
|
712
720
|
}
|
|
713
|
-
function toESBuildError(error) {
|
|
714
|
-
const { filename, frame, start } = error;
|
|
721
|
+
function toESBuildError(error, options) {
|
|
722
|
+
const { filename, frame, start, stack } = error;
|
|
715
723
|
const partialMessage = {
|
|
716
724
|
text: buildExtendedLogMessage(error)
|
|
717
725
|
};
|
|
@@ -723,6 +731,9 @@ function toESBuildError(error) {
|
|
|
723
731
|
lineText: lineFromFrame(start.line, frame)
|
|
724
732
|
};
|
|
725
733
|
}
|
|
734
|
+
if (options.isBuild || options.isDebug || !frame) {
|
|
735
|
+
partialMessage.detail = stack;
|
|
736
|
+
}
|
|
726
737
|
return partialMessage;
|
|
727
738
|
}
|
|
728
739
|
function lineFromFrame(lineNo, frame) {
|
|
@@ -755,7 +766,7 @@ function esbuildSveltePlugin(options) {
|
|
|
755
766
|
const contents = await compileSvelte(options, { filename, code });
|
|
756
767
|
return { contents };
|
|
757
768
|
} catch (e) {
|
|
758
|
-
return { errors: [toESBuildError(e)] };
|
|
769
|
+
return { errors: [toESBuildError(e, options)] };
|
|
759
770
|
}
|
|
760
771
|
});
|
|
761
772
|
}
|
|
@@ -788,7 +799,12 @@ async function compileSvelte(options, { filename, code }) {
|
|
|
788
799
|
});
|
|
789
800
|
let preprocessed;
|
|
790
801
|
if (options.preprocess) {
|
|
791
|
-
|
|
802
|
+
try {
|
|
803
|
+
preprocessed = await preprocess2(code, options.preprocess, { filename });
|
|
804
|
+
} catch (e) {
|
|
805
|
+
e.message = `Error while preprocessing ${filename}${e.message ? ` - ${e.message}` : ""}`;
|
|
806
|
+
throw e;
|
|
807
|
+
}
|
|
792
808
|
if (preprocessed.map)
|
|
793
809
|
compileOptions.sourcemap = preprocessed.map;
|
|
794
810
|
}
|
|
@@ -1073,7 +1089,8 @@ async function preResolveOptions(inlineOptions = {}, viteUserConfig, viteEnv) {
|
|
|
1073
1089
|
experimental: __spreadValues(__spreadValues(__spreadValues({}, defaultOptions == null ? void 0 : defaultOptions.experimental), svelteConfig == null ? void 0 : svelteConfig.experimental), inlineOptions == null ? void 0 : inlineOptions.experimental),
|
|
1074
1090
|
root: viteConfigWithResolvedRoot.root,
|
|
1075
1091
|
isBuild: viteEnv.command === "build",
|
|
1076
|
-
isServe: viteEnv.command === "serve"
|
|
1092
|
+
isServe: viteEnv.command === "serve",
|
|
1093
|
+
isDebug: process.env.DEBUG != null
|
|
1077
1094
|
});
|
|
1078
1095
|
if (svelteConfig == null ? void 0 : svelteConfig.configFile) {
|
|
1079
1096
|
merged.configFile = svelteConfig.configFile;
|
|
@@ -1581,7 +1598,7 @@ function svelte(inlineOptions) {
|
|
|
1581
1598
|
try {
|
|
1582
1599
|
compileData = await compileSvelte2(svelteRequest, code, options);
|
|
1583
1600
|
} catch (e) {
|
|
1584
|
-
throw toRollupError(e);
|
|
1601
|
+
throw toRollupError(e, options);
|
|
1585
1602
|
}
|
|
1586
1603
|
logCompilerWarnings(compileData.compiled.warnings, options);
|
|
1587
1604
|
cache.update(compileData);
|