@solidjs/start 2.0.0-beta.8 → 2.0.0-rc.1

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.
@@ -1,8 +1,20 @@
1
1
  import { createMemo, createResource } from "solid-js";
2
2
  import getSourceMap from "./get-source-map.js";
3
+ const HTTP_URL_REGEX = /^https?:\/\//;
4
+ const LEADING_SLASH_REGEX = /^\/+/;
5
+ // Frames from an SSR error carry filesystem paths (or file:// URLs) rather
6
+ // than the http URL the module is served from. Their positions are already
7
+ // mapped back to the original source by the Vite module runner, unlike
8
+ // client frames whose positions refer to the compiled module.
9
+ function isServerSource(path) {
10
+ return !HTTP_URL_REGEX.test(path);
11
+ }
3
12
  function getActualFileSource(path) {
4
13
  if (path.startsWith("file://")) {
5
- return "/_build/@fs" + path.substring("file://".length);
14
+ return "/@fs/" + path.substring("file://".length).replace(LEADING_SLASH_REGEX, "");
15
+ }
16
+ if (isServerSource(path)) {
17
+ return "/@fs/" + path.replace(LEADING_SLASH_REGEX, "");
6
18
  }
7
19
  return path;
8
20
  }
@@ -16,16 +28,18 @@ export function createStackFrame(stackframe, isCompiled) {
16
28
  if (!source.fileName) {
17
29
  return null;
18
30
  }
19
- const response = await fetch(getActualFileSource(source.fileName));
31
+ const url = getActualFileSource(source.fileName);
32
+ const response = await fetch(url);
20
33
  if (!response.ok) {
21
34
  return null;
22
35
  }
23
36
  const content = await response.text();
24
- const sourceMap = await getSourceMap(source.fileName, content);
37
+ const sourceMap = await getSourceMap(url, content);
25
38
  return {
26
39
  source,
27
40
  content,
28
41
  sourceMap,
42
+ isServer: isServerSource(source.fileName),
29
43
  };
30
44
  });
31
45
  const info = createMemo(() => {
@@ -33,16 +47,36 @@ export function createStackFrame(stackframe, isCompiled) {
33
47
  if (!current) {
34
48
  return undefined;
35
49
  }
36
- const { source, content, sourceMap } = current;
50
+ const { source, content, sourceMap, isServer } = current;
37
51
  if (!isCompiled() && source.line && source.column && sourceMap) {
38
- const result = sourceMap.originalPositionFor({
39
- line: source.line,
40
- column: source.column,
41
- });
42
- return {
43
- ...result,
44
- content: sourceMap.sourceContentFor(result.source),
45
- };
52
+ if (isServer) {
53
+ // The position is already original; only the original content needs
54
+ // to be pulled out of the source map.
55
+ const originalContent = sourceMap.sources.length
56
+ ? sourceMap.sourceContentFor(sourceMap.sources[0], true)
57
+ : null;
58
+ if (originalContent) {
59
+ return {
60
+ source: source.fileName,
61
+ line: source.line,
62
+ column: source.column,
63
+ name: source.functionName,
64
+ content: originalContent,
65
+ };
66
+ }
67
+ }
68
+ else {
69
+ const result = sourceMap.originalPositionFor({
70
+ line: source.line,
71
+ column: source.column,
72
+ });
73
+ if (result.source) {
74
+ return {
75
+ ...result,
76
+ content: sourceMap.sourceContentFor(result.source, true),
77
+ };
78
+ }
79
+ }
46
80
  }
47
81
  return {
48
82
  source: source.fileName,
package/env.d.ts CHANGED
@@ -7,3 +7,15 @@ declare namespace App {
7
7
  [key: string | symbol]: any;
8
8
  }
9
9
  }
10
+
11
+ /**
12
+ * Import `server-only` to ensure this module is never bundled for the client.
13
+ * Importing it in a client module will throw a build error.
14
+ */
15
+ declare module "server-only" {}
16
+
17
+ /**
18
+ * Import `client-only` to ensure this module is never bundled for the server.
19
+ * Importing it in a server module will throw a build error.
20
+ */
21
+ declare module "client-only" {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidjs/start",
3
- "version": "2.0.0-beta.8",
3
+ "version": "2.0.0-rc.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",