@sveltejs/kit 1.0.0-next.554 → 1.0.0-next.555

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.554",
3
+ "version": "1.0.0-next.555",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -1,5 +1,4 @@
1
- import { relative } from 'path';
2
- import { posixify, resolve_entry } from '../../utils/filesystem.js';
1
+ import { relative_path, resolve_entry } from '../../utils/filesystem.js';
3
2
  import { s } from '../../utils/misc.js';
4
3
  import { trim, write_if_changed } from './utils.js';
5
4
 
@@ -20,14 +19,16 @@ export function write_client_manifest(config, manifest_data, output) {
20
19
 
21
20
  if (node.shared) {
22
21
  declarations.push(
23
- `import * as shared from ${s(relative(`${output}/nodes`, node.shared))};`,
22
+ `import * as shared from ${s(relative_path(`${output}/nodes`, node.shared))};`,
24
23
  `export { shared };`
25
24
  );
26
25
  }
27
26
 
28
27
  if (node.component) {
29
28
  declarations.push(
30
- `export { default as component } from ${s(relative(`${output}/nodes`, node.component))};`
29
+ `export { default as component } from ${s(
30
+ relative_path(`${output}/nodes`, node.component)
31
+ )};`
31
32
  );
32
33
  }
33
34
 
@@ -86,7 +87,7 @@ export function write_client_manifest(config, manifest_data, output) {
86
87
  write_if_changed(
87
88
  `${output}/client-manifest.js`,
88
89
  trim(`
89
- ${hooks_file ? `import * as client_hooks from '${posixify(relative(output, hooks_file))}';` : ''}
90
+ ${hooks_file ? `import * as client_hooks from '${relative_path(output, hooks_file)}';` : ''}
90
91
 
91
92
  export { matchers } from './client-matchers.js';
92
93
 
@@ -1,5 +1,5 @@
1
- import path from 'path';
2
1
  import { s } from '../../utils/misc.js';
2
+ import { relative_path } from '../../utils/filesystem.js';
3
3
  import { write_if_changed } from './utils.js';
4
4
 
5
5
  /**
@@ -13,7 +13,7 @@ export function write_matchers(manifest_data, output) {
13
13
  for (const key in manifest_data.matchers) {
14
14
  const src = manifest_data.matchers[key];
15
15
 
16
- imports.push(`import { match as ${key} } from ${s(path.relative(output, src))};`);
16
+ imports.push(`import { match as ${key} } from ${s(relative_path(output, src))};`);
17
17
  matchers.push(key);
18
18
  }
19
19
 
@@ -113,7 +113,7 @@ export function posixify(str) {
113
113
  }
114
114
 
115
115
  /**
116
- * Like `path.join`, but posixified and with a leading ./ if necessary
116
+ * Like `path.join`, but posixified and with a leading `./` if necessary
117
117
  * @param {string[]} str
118
118
  */
119
119
  export function join_relative(...str) {
@@ -124,6 +124,17 @@ export function join_relative(...str) {
124
124
  return result;
125
125
  }
126
126
 
127
+ /**
128
+ * Like `path.relative`, but always posixified and with a leading `./` if necessary.
129
+ * Useful for JS imports so the path can safely reside inside of `node_modules`.
130
+ * Otherwise paths could be falsely interpreted as package paths.
131
+ * @param {string} from
132
+ * @param {string} to
133
+ */
134
+ export function relative_path(from, to) {
135
+ return join_relative(path.relative(from, to));
136
+ }
137
+
127
138
  /**
128
139
  * Prepend given path with `/@fs` prefix
129
140
  * @param {string} str