vike 0.4.167-commit-c08a6bb → 0.4.167-commit-4996ef0
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/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +92 -97
- package/dist/cjs/utils/assertPathIsFilesystemAbsolute.js +3 -3
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +93 -98
- package/dist/esm/utils/assertPathIsFilesystemAbsolute.js +3 -3
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +1 -1
|
@@ -82,98 +82,95 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
82
82
|
// Esbuild still sometimes removes unused imports because of TypeScript: https://github.com/evanw/esbuild/issues/3034
|
|
83
83
|
treeShaking: false,
|
|
84
84
|
minify: false,
|
|
85
|
-
metafile:
|
|
86
|
-
bundle:
|
|
85
|
+
metafile: true,
|
|
86
|
+
bundle: true
|
|
87
87
|
};
|
|
88
|
-
let pointerImports;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
(0, utils_js_1.assert)(resolved.path);
|
|
122
|
-
resolved.path = (0, utils_js_1.toPosixPath)(resolved.path);
|
|
123
|
-
// vike-{react,vue,solid} follow the convention that their config export resolves to a file named +config.js
|
|
124
|
-
// - This is temporary, see comment below.
|
|
125
|
-
const isVikeExtensionConfigImport = resolved.path.endsWith('+config.js');
|
|
126
|
-
const isPointerImport =
|
|
88
|
+
let pointerImports = {};
|
|
89
|
+
options.plugins = [
|
|
90
|
+
// Determine whether an import should be:
|
|
91
|
+
// - A pointer import
|
|
92
|
+
// - Externalized
|
|
93
|
+
{
|
|
94
|
+
name: 'vike-esbuild-plugin',
|
|
95
|
+
setup(build) {
|
|
96
|
+
// https://github.com/evanw/esbuild/issues/3095#issuecomment-1546916366
|
|
97
|
+
const useEsbuildResolver = 'useEsbuildResolver';
|
|
98
|
+
// https://github.com/brillout/esbuild-playground
|
|
99
|
+
build.onResolve({ filter: /.*/ }, async (args) => {
|
|
100
|
+
if (args.kind !== 'import-statement')
|
|
101
|
+
return;
|
|
102
|
+
if (args.pluginData?.[useEsbuildResolver])
|
|
103
|
+
return;
|
|
104
|
+
const { path, ...opts } = args;
|
|
105
|
+
opts.pluginData = { [useEsbuildResolver]: true };
|
|
106
|
+
const resolved = await build.resolve(path, opts);
|
|
107
|
+
if (resolved.errors.length > 0) {
|
|
108
|
+
/* We could do the following to let Node.js throw the error, but we don't because the error shown by esbuild is prettier: the Node.js error refers to the transpiled [build-f7i251e0iwnw]+config.ts.mjs file which isn't that nice, whereas esbuild refers to the source +config.ts file.
|
|
109
|
+
pointerImports[args.path] = false
|
|
110
|
+
return { external: true }
|
|
111
|
+
*/
|
|
112
|
+
// Let esbuild throw the error. (It throws a nice & pretty error.)
|
|
113
|
+
return resolved;
|
|
114
|
+
}
|
|
115
|
+
(0, utils_js_1.assert)(resolved.path);
|
|
116
|
+
resolved.path = (0, utils_js_1.toPosixPath)(resolved.path);
|
|
117
|
+
// vike-{react,vue,solid} follow the convention that their config export resolves to a file named +config.js
|
|
118
|
+
// - This is temporary, see comment below.
|
|
119
|
+
const isVikeExtensionConfigImport = resolved.path.endsWith('+config.js');
|
|
120
|
+
const isPointerImport = transformImports === 'all' ||
|
|
127
121
|
// .jsx, .vue, .svg, ... => obviously not config code
|
|
128
122
|
!(0, utils_js_1.isJavaScriptFile)(resolved.path) ||
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
name: 'vike:dependency-tracker',
|
|
156
|
-
setup(b) {
|
|
157
|
-
b.onLoad({ filter: /./ }, (args) => {
|
|
158
|
-
// We collect the dependency `args.path` in case the bulid fails (upon build error => error is thrown => no metafile)
|
|
159
|
-
let { path } = args;
|
|
160
|
-
path = (0, utils_js_1.toPosixPath)(path);
|
|
161
|
-
getVikeConfig_js_1.vikeConfigDependencies.add(path);
|
|
162
|
-
return undefined;
|
|
163
|
-
});
|
|
164
|
-
/* To exhaustively collect all dependencies upon build failure, we would also need to use onResolve().
|
|
165
|
-
* - Because onLoad() isn't call if the config dependency can't be resolved.
|
|
166
|
-
* - For example, the following breaks auto-reload (the config is stuck in its error state and the user needs to touch the importer for the config to reload):
|
|
167
|
-
* ```bash
|
|
168
|
-
* mv ./some-config-dependency.js /tmp/ && mv /tmp/some-config-dependency.js .
|
|
169
|
-
* ```
|
|
170
|
-
* - But implementing a fix is complex and isn't worth it.
|
|
171
|
-
b.onResolve(...)
|
|
172
|
-
*/
|
|
173
|
-
}
|
|
123
|
+
// Import of a Vike extension config => make it a pointer import because we want to show nice error messages (that can display whether a configas been set by the user or by a Vike extension).
|
|
124
|
+
// - We should have Node.js directly load vike-{react,vue,solid} while enforcing Vike extensions to set 'name' in their +config.js file.
|
|
125
|
+
// - vike@0.4.162 already started soft-requiring Vike extensions to set the name config
|
|
126
|
+
isVikeExtensionConfigImport ||
|
|
127
|
+
// Cannot be resolved by esbuild => take a leap of faith and make it a pointer import.
|
|
128
|
+
// - For example if esbuild cannot resolve a path alias while Vite can.
|
|
129
|
+
// - When tsconfig.js#compilerOptions.paths is set, then esbuild is able to resolve the path alias.
|
|
130
|
+
resolved.errors.length > 0;
|
|
131
|
+
pointerImports[resolved.path] = isPointerImport;
|
|
132
|
+
(0, utils_js_1.assertPosixPath)(resolved.path);
|
|
133
|
+
const isExternal = isPointerImport ||
|
|
134
|
+
// Performance: npm package imports that aren't pointer imports can be externalized. For example, if Vike eventually adds support for setting Vite configs in the vike.config.js file, then the user may import a Vite plugin in his vike.config.js file. (We could as well let esbuild always transpile /node_modules/ code but it would be useless and would unnecessarily slow down transpilation.)
|
|
135
|
+
resolved.path.includes('/node_modules/');
|
|
136
|
+
if (debug.isActivated)
|
|
137
|
+
debug('onResolved()', { args, resolved, isPointerImport, isExternal });
|
|
138
|
+
// We need esbuild to resolve path aliases so that we can use:
|
|
139
|
+
// isNpmPackageImport(str, { cannotBePathAlias: true })
|
|
140
|
+
// assertIsNpmPackageImport()
|
|
141
|
+
(0, utils_js_1.assertPathIsFilesystemAbsolute)(resolved.path);
|
|
142
|
+
if (isExternal) {
|
|
143
|
+
return { external: true, path: resolved.path };
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
return resolved;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
174
149
|
}
|
|
175
|
-
|
|
176
|
-
|
|
150
|
+
},
|
|
151
|
+
// Track dependencies
|
|
152
|
+
{
|
|
153
|
+
name: 'vike:dependency-tracker',
|
|
154
|
+
setup(b) {
|
|
155
|
+
b.onLoad({ filter: /./ }, (args) => {
|
|
156
|
+
// We collect the dependency `args.path` in case the bulid fails (upon build error => error is thrown => no metafile)
|
|
157
|
+
let { path } = args;
|
|
158
|
+
path = (0, utils_js_1.toPosixPath)(path);
|
|
159
|
+
getVikeConfig_js_1.vikeConfigDependencies.add(path);
|
|
160
|
+
return undefined;
|
|
161
|
+
});
|
|
162
|
+
/* To exhaustively collect all dependencies upon build failure, we would also need to use onResolve().
|
|
163
|
+
* - Because onLoad() isn't call if the config dependency can't be resolved.
|
|
164
|
+
* - For example, the following breaks auto-reload (the config is stuck in its error state and the user needs to touch the importer for the config to reload):
|
|
165
|
+
* ```bash
|
|
166
|
+
* mv ./some-config-dependency.js /tmp/ && mv /tmp/some-config-dependency.js .
|
|
167
|
+
* ```
|
|
168
|
+
* - But implementing a fix is complex and isn't worth it.
|
|
169
|
+
b.onResolve(...)
|
|
170
|
+
*/
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
];
|
|
177
174
|
let result;
|
|
178
175
|
try {
|
|
179
176
|
result = await (0, esbuild_1.build)(options);
|
|
@@ -183,15 +180,13 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
183
180
|
throw err;
|
|
184
181
|
}
|
|
185
182
|
// Track dependencies
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
});
|
|
194
|
-
}
|
|
183
|
+
(0, utils_js_1.assert)(result.metafile);
|
|
184
|
+
Object.keys(result.metafile.inputs).forEach((filePathRelative) => {
|
|
185
|
+
filePathRelative = (0, utils_js_1.toPosixPath)(filePathRelative);
|
|
186
|
+
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
187
|
+
const filePathAbsoluteFilesystem = path_1.default.posix.join(userRootDir, filePathRelative);
|
|
188
|
+
getVikeConfig_js_1.vikeConfigDependencies.add(filePathAbsoluteFilesystem);
|
|
189
|
+
});
|
|
195
190
|
const code = result.outputFiles[0].text;
|
|
196
191
|
(0, utils_js_1.assert)(typeof code === 'string');
|
|
197
192
|
return { code, pointerImports };
|
|
@@ -11,11 +11,11 @@ const filesystemPathHandling_js_1 = require("./filesystemPathHandling.js");
|
|
|
11
11
|
function assertPathIsFilesystemAbsolute(p) {
|
|
12
12
|
(0, filesystemPathHandling_js_1.assertPosixPath)(p);
|
|
13
13
|
(0, assert_js_1.assert)(!p.startsWith('/@fs/'));
|
|
14
|
-
if (process.platform
|
|
15
|
-
(0, assert_js_1.assert)(
|
|
14
|
+
if (process.platform !== 'win32') {
|
|
15
|
+
(0, assert_js_1.assert)(p.startsWith('/'));
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
18
|
-
(0, assert_js_1.assert)(
|
|
18
|
+
(0, assert_js_1.assert)(path_1.default.win32.isAbsolute(p));
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
exports.assertPathIsFilesystemAbsolute = assertPathIsFilesystemAbsolute;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PROJECT_VERSION = exports.projectInfo = void 0;
|
|
4
|
-
const PROJECT_VERSION = '0.4.167-commit-
|
|
4
|
+
const PROJECT_VERSION = '0.4.167-commit-4996ef0';
|
|
5
5
|
exports.PROJECT_VERSION = PROJECT_VERSION;
|
|
6
6
|
const projectInfo = {
|
|
7
7
|
projectName: 'Vike',
|
|
@@ -2,7 +2,7 @@ export { transformFileImports };
|
|
|
2
2
|
export { parseImportData };
|
|
3
3
|
export { isImportData };
|
|
4
4
|
export type { ImportData };
|
|
5
|
-
declare function transformFileImports(code: string, filePathToShowToUser2: string, pointerImports:
|
|
5
|
+
declare function transformFileImports(code: string, filePathToShowToUser2: string, pointerImports: Record<string, boolean> | 'all', skipWarnings?: true): string | null;
|
|
6
6
|
/**
|
|
7
7
|
* Data Structure holding info about import statement:
|
|
8
8
|
* `import { someExport as someImport } from './some-file'`
|
|
@@ -7,7 +7,7 @@ import fs from 'fs';
|
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import pc from '@brillout/picocolors';
|
|
9
9
|
import { import_ } from '@brillout/import';
|
|
10
|
-
import { assertPosixPath, getRandomId, assertIsNotProductionRuntime, assert, assertWarning, isObject, toPosixPath, assertUsage, isJavaScriptFile, createDebugger } from '../../../../utils.js';
|
|
10
|
+
import { assertPosixPath, getRandomId, assertIsNotProductionRuntime, assert, assertWarning, isObject, toPosixPath, assertUsage, isJavaScriptFile, createDebugger, assertPathIsFilesystemAbsolute } from '../../../../utils.js';
|
|
11
11
|
import { transformFileImports } from './transformFileImports.js';
|
|
12
12
|
import { vikeConfigDependencies } from '../getVikeConfig.js';
|
|
13
13
|
import 'source-map-support/register.js';
|
|
@@ -79,98 +79,95 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
79
79
|
// Esbuild still sometimes removes unused imports because of TypeScript: https://github.com/evanw/esbuild/issues/3034
|
|
80
80
|
treeShaking: false,
|
|
81
81
|
minify: false,
|
|
82
|
-
metafile:
|
|
83
|
-
bundle:
|
|
82
|
+
metafile: true,
|
|
83
|
+
bundle: true
|
|
84
84
|
};
|
|
85
|
-
let pointerImports;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
assert(resolved.path);
|
|
119
|
-
resolved.path = toPosixPath(resolved.path);
|
|
120
|
-
// vike-{react,vue,solid} follow the convention that their config export resolves to a file named +config.js
|
|
121
|
-
// - This is temporary, see comment below.
|
|
122
|
-
const isVikeExtensionConfigImport = resolved.path.endsWith('+config.js');
|
|
123
|
-
const isPointerImport =
|
|
85
|
+
let pointerImports = {};
|
|
86
|
+
options.plugins = [
|
|
87
|
+
// Determine whether an import should be:
|
|
88
|
+
// - A pointer import
|
|
89
|
+
// - Externalized
|
|
90
|
+
{
|
|
91
|
+
name: 'vike-esbuild-plugin',
|
|
92
|
+
setup(build) {
|
|
93
|
+
// https://github.com/evanw/esbuild/issues/3095#issuecomment-1546916366
|
|
94
|
+
const useEsbuildResolver = 'useEsbuildResolver';
|
|
95
|
+
// https://github.com/brillout/esbuild-playground
|
|
96
|
+
build.onResolve({ filter: /.*/ }, async (args) => {
|
|
97
|
+
if (args.kind !== 'import-statement')
|
|
98
|
+
return;
|
|
99
|
+
if (args.pluginData?.[useEsbuildResolver])
|
|
100
|
+
return;
|
|
101
|
+
const { path, ...opts } = args;
|
|
102
|
+
opts.pluginData = { [useEsbuildResolver]: true };
|
|
103
|
+
const resolved = await build.resolve(path, opts);
|
|
104
|
+
if (resolved.errors.length > 0) {
|
|
105
|
+
/* We could do the following to let Node.js throw the error, but we don't because the error shown by esbuild is prettier: the Node.js error refers to the transpiled [build-f7i251e0iwnw]+config.ts.mjs file which isn't that nice, whereas esbuild refers to the source +config.ts file.
|
|
106
|
+
pointerImports[args.path] = false
|
|
107
|
+
return { external: true }
|
|
108
|
+
*/
|
|
109
|
+
// Let esbuild throw the error. (It throws a nice & pretty error.)
|
|
110
|
+
return resolved;
|
|
111
|
+
}
|
|
112
|
+
assert(resolved.path);
|
|
113
|
+
resolved.path = toPosixPath(resolved.path);
|
|
114
|
+
// vike-{react,vue,solid} follow the convention that their config export resolves to a file named +config.js
|
|
115
|
+
// - This is temporary, see comment below.
|
|
116
|
+
const isVikeExtensionConfigImport = resolved.path.endsWith('+config.js');
|
|
117
|
+
const isPointerImport = transformImports === 'all' ||
|
|
124
118
|
// .jsx, .vue, .svg, ... => obviously not config code
|
|
125
119
|
!isJavaScriptFile(resolved.path) ||
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
name: 'vike:dependency-tracker',
|
|
153
|
-
setup(b) {
|
|
154
|
-
b.onLoad({ filter: /./ }, (args) => {
|
|
155
|
-
// We collect the dependency `args.path` in case the bulid fails (upon build error => error is thrown => no metafile)
|
|
156
|
-
let { path } = args;
|
|
157
|
-
path = toPosixPath(path);
|
|
158
|
-
vikeConfigDependencies.add(path);
|
|
159
|
-
return undefined;
|
|
160
|
-
});
|
|
161
|
-
/* To exhaustively collect all dependencies upon build failure, we would also need to use onResolve().
|
|
162
|
-
* - Because onLoad() isn't call if the config dependency can't be resolved.
|
|
163
|
-
* - For example, the following breaks auto-reload (the config is stuck in its error state and the user needs to touch the importer for the config to reload):
|
|
164
|
-
* ```bash
|
|
165
|
-
* mv ./some-config-dependency.js /tmp/ && mv /tmp/some-config-dependency.js .
|
|
166
|
-
* ```
|
|
167
|
-
* - But implementing a fix is complex and isn't worth it.
|
|
168
|
-
b.onResolve(...)
|
|
169
|
-
*/
|
|
170
|
-
}
|
|
120
|
+
// Import of a Vike extension config => make it a pointer import because we want to show nice error messages (that can display whether a configas been set by the user or by a Vike extension).
|
|
121
|
+
// - We should have Node.js directly load vike-{react,vue,solid} while enforcing Vike extensions to set 'name' in their +config.js file.
|
|
122
|
+
// - vike@0.4.162 already started soft-requiring Vike extensions to set the name config
|
|
123
|
+
isVikeExtensionConfigImport ||
|
|
124
|
+
// Cannot be resolved by esbuild => take a leap of faith and make it a pointer import.
|
|
125
|
+
// - For example if esbuild cannot resolve a path alias while Vite can.
|
|
126
|
+
// - When tsconfig.js#compilerOptions.paths is set, then esbuild is able to resolve the path alias.
|
|
127
|
+
resolved.errors.length > 0;
|
|
128
|
+
pointerImports[resolved.path] = isPointerImport;
|
|
129
|
+
assertPosixPath(resolved.path);
|
|
130
|
+
const isExternal = isPointerImport ||
|
|
131
|
+
// Performance: npm package imports that aren't pointer imports can be externalized. For example, if Vike eventually adds support for setting Vite configs in the vike.config.js file, then the user may import a Vite plugin in his vike.config.js file. (We could as well let esbuild always transpile /node_modules/ code but it would be useless and would unnecessarily slow down transpilation.)
|
|
132
|
+
resolved.path.includes('/node_modules/');
|
|
133
|
+
if (debug.isActivated)
|
|
134
|
+
debug('onResolved()', { args, resolved, isPointerImport, isExternal });
|
|
135
|
+
// We need esbuild to resolve path aliases so that we can use:
|
|
136
|
+
// isNpmPackageImport(str, { cannotBePathAlias: true })
|
|
137
|
+
// assertIsNpmPackageImport()
|
|
138
|
+
assertPathIsFilesystemAbsolute(resolved.path);
|
|
139
|
+
if (isExternal) {
|
|
140
|
+
return { external: true, path: resolved.path };
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
return resolved;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
171
146
|
}
|
|
172
|
-
|
|
173
|
-
|
|
147
|
+
},
|
|
148
|
+
// Track dependencies
|
|
149
|
+
{
|
|
150
|
+
name: 'vike:dependency-tracker',
|
|
151
|
+
setup(b) {
|
|
152
|
+
b.onLoad({ filter: /./ }, (args) => {
|
|
153
|
+
// We collect the dependency `args.path` in case the bulid fails (upon build error => error is thrown => no metafile)
|
|
154
|
+
let { path } = args;
|
|
155
|
+
path = toPosixPath(path);
|
|
156
|
+
vikeConfigDependencies.add(path);
|
|
157
|
+
return undefined;
|
|
158
|
+
});
|
|
159
|
+
/* To exhaustively collect all dependencies upon build failure, we would also need to use onResolve().
|
|
160
|
+
* - Because onLoad() isn't call if the config dependency can't be resolved.
|
|
161
|
+
* - For example, the following breaks auto-reload (the config is stuck in its error state and the user needs to touch the importer for the config to reload):
|
|
162
|
+
* ```bash
|
|
163
|
+
* mv ./some-config-dependency.js /tmp/ && mv /tmp/some-config-dependency.js .
|
|
164
|
+
* ```
|
|
165
|
+
* - But implementing a fix is complex and isn't worth it.
|
|
166
|
+
b.onResolve(...)
|
|
167
|
+
*/
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
];
|
|
174
171
|
let result;
|
|
175
172
|
try {
|
|
176
173
|
result = await build(options);
|
|
@@ -180,15 +177,13 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
180
177
|
throw err;
|
|
181
178
|
}
|
|
182
179
|
// Track dependencies
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
});
|
|
191
|
-
}
|
|
180
|
+
assert(result.metafile);
|
|
181
|
+
Object.keys(result.metafile.inputs).forEach((filePathRelative) => {
|
|
182
|
+
filePathRelative = toPosixPath(filePathRelative);
|
|
183
|
+
assertPosixPath(userRootDir);
|
|
184
|
+
const filePathAbsoluteFilesystem = path.posix.join(userRootDir, filePathRelative);
|
|
185
|
+
vikeConfigDependencies.add(filePathAbsoluteFilesystem);
|
|
186
|
+
});
|
|
192
187
|
const code = result.outputFiles[0].text;
|
|
193
188
|
assert(typeof code === 'string');
|
|
194
189
|
return { code, pointerImports };
|
|
@@ -6,10 +6,10 @@ import { assertPosixPath } from './filesystemPathHandling.js';
|
|
|
6
6
|
function assertPathIsFilesystemAbsolute(p) {
|
|
7
7
|
assertPosixPath(p);
|
|
8
8
|
assert(!p.startsWith('/@fs/'));
|
|
9
|
-
if (process.platform
|
|
10
|
-
assert(
|
|
9
|
+
if (process.platform !== 'win32') {
|
|
10
|
+
assert(p.startsWith('/'));
|
|
11
11
|
}
|
|
12
12
|
else {
|
|
13
|
-
assert(
|
|
13
|
+
assert(path.win32.isAbsolute(p));
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { projectInfo };
|
|
2
2
|
export { PROJECT_VERSION };
|
|
3
|
-
declare const PROJECT_VERSION: "0.4.167-commit-
|
|
3
|
+
declare const PROJECT_VERSION: "0.4.167-commit-4996ef0";
|
|
4
4
|
declare const projectInfo: {
|
|
5
5
|
projectName: "Vike";
|
|
6
|
-
projectVersion: "0.4.167-commit-
|
|
6
|
+
projectVersion: "0.4.167-commit-4996ef0";
|
|
7
7
|
};
|