vike 0.4.165 → 0.4.166-commit-a5e2596
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/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/baseUrls.js +1 -1
- package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +6 -2
- package/dist/cjs/node/plugin/plugins/buildConfig.js +78 -63
- package/dist/cjs/node/plugin/plugins/commonConfig/assertResolveAlias.js +14 -1
- package/dist/cjs/node/plugin/plugins/config/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +18 -23
- package/dist/cjs/node/plugin/plugins/envVars.js +3 -2
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +9 -9
- package/dist/cjs/node/plugin/plugins/fileEnv.js +6 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +6 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +0 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +53 -24
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +6 -6
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +10 -25
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +32 -35
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +18 -26
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +26 -21
- package/dist/cjs/node/plugin/shared/getFilePath.js +142 -0
- package/dist/cjs/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +3 -8
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +2 -1
- package/dist/cjs/node/plugin/utils.js +1 -1
- package/dist/cjs/node/prerender/runPrerender.js +6 -7
- package/dist/cjs/node/prerender/utils.js +2 -1
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +1 -0
- package/dist/cjs/node/runtime/html/injectAssets/injectHtmlTags.js +1 -1
- package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +3 -3
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -1
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +31 -33
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +9 -8
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +6 -12
- package/dist/cjs/node/runtime/renderPage/logErrorHint.js +5 -0
- package/dist/cjs/node/runtime/renderPage.js +34 -21
- package/dist/cjs/node/runtime/utils.js +0 -1
- package/dist/cjs/shared/page-configs/FilePath.js +2 -0
- package/dist/cjs/shared/route/abort.js +2 -1
- package/dist/cjs/shared/route/executeGuardHook.js +2 -1
- package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +2 -1
- package/dist/cjs/shared/route/index.js +2 -3
- package/dist/cjs/shared/route/utils.js +0 -1
- package/dist/cjs/utils/assert.js +2 -0
- package/dist/cjs/utils/assertPathIsFilesystemAbsolute.js +1 -0
- package/dist/cjs/utils/assertSingleInstance.js +6 -5
- package/dist/cjs/utils/assertVersion.js +4 -1
- package/dist/cjs/utils/getGlobalObject.js +21 -6
- package/dist/cjs/utils/isNpmPackage.js +11 -5
- package/dist/cjs/utils/parseUrl.js +8 -1
- package/dist/cjs/utils/projectInfo.js +1 -4
- package/dist/esm/client/client-routing-runtime/history.d.ts +1 -1
- package/dist/esm/client/client-routing-runtime/history.js +5 -5
- package/dist/esm/client/client-routing-runtime/onBrowserHistoryNavigation.js +1 -1
- package/dist/esm/node/plugin/index.js +1 -1
- package/dist/esm/node/plugin/plugins/baseUrls.js +1 -1
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +6 -2
- package/dist/esm/node/plugin/plugins/buildConfig.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/buildConfig.js +79 -64
- package/dist/esm/node/plugin/plugins/commonConfig/assertResolveAlias.js +14 -1
- package/dist/esm/node/plugin/plugins/config/index.js +1 -1
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +19 -24
- package/dist/esm/node/plugin/plugins/envVars.js +4 -3
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +9 -9
- package/dist/esm/node/plugin/plugins/fileEnv.js +7 -4
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +7 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +0 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +54 -25
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +6 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +11 -26
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.d.ts +2 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +32 -35
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +18 -26
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +3 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +26 -21
- package/dist/esm/node/plugin/shared/getFilePath.d.ts +21 -0
- package/dist/esm/node/plugin/shared/getFilePath.js +136 -0
- package/dist/esm/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +4 -9
- package/dist/esm/node/plugin/shared/loggerNotProd.js +2 -1
- package/dist/esm/node/plugin/utils.d.ts +1 -1
- package/dist/esm/node/plugin/utils.js +1 -1
- package/dist/esm/node/prerender/runPrerender.js +2 -3
- package/dist/esm/node/prerender/utils.d.ts +2 -1
- package/dist/esm/node/prerender/utils.js +2 -1
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +1 -0
- package/dist/esm/node/runtime/html/injectAssets/injectHtmlTags.js +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +32 -34
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +9 -8
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +7 -13
- package/dist/esm/node/runtime/renderPage/logErrorHint.js +2 -0
- package/dist/esm/node/runtime/renderPage.js +34 -21
- package/dist/esm/node/runtime/utils.d.ts +0 -1
- package/dist/esm/node/runtime/utils.js +0 -1
- package/dist/esm/shared/page-configs/Config/PageContextConfig.d.ts +1 -1
- package/dist/esm/shared/page-configs/FilePath.d.ts +64 -0
- package/dist/esm/shared/page-configs/FilePath.js +1 -0
- package/dist/esm/shared/page-configs/PageConfig.d.ts +1 -42
- package/dist/esm/shared/route/abort.js +2 -1
- package/dist/esm/shared/route/executeGuardHook.js +2 -1
- package/dist/esm/shared/route/executeOnBeforeRouteHook.js +2 -1
- package/dist/esm/shared/route/index.js +2 -3
- package/dist/esm/shared/route/utils.d.ts +0 -1
- package/dist/esm/shared/route/utils.js +0 -1
- package/dist/esm/utils/assert.js +2 -0
- package/dist/esm/utils/assertPathIsFilesystemAbsolute.js +1 -0
- package/dist/esm/utils/assertSingleInstance.d.ts +2 -2
- package/dist/esm/utils/assertSingleInstance.js +5 -4
- package/dist/esm/utils/assertVersion.js +4 -1
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/getGlobalObject.d.ts +6 -1
- package/dist/esm/utils/getGlobalObject.js +22 -6
- package/dist/esm/utils/isNpmPackage.d.ts +5 -7
- package/dist/esm/utils/isNpmPackage.js +15 -4
- package/dist/esm/utils/parseUrl.js +8 -1
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -4
- package/package.json +26 -14
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.js +0 -33
- package/dist/cjs/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -19
- package/dist/cjs/utils/getFilePathAbsolute.js +0 -70
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.d.ts +0 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.js +0 -27
- package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.d.ts +0 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -16
- package/dist/esm/utils/getFilePathAbsolute.d.ts +0 -5
- package/dist/esm/utils/getFilePathAbsolute.js +0 -64
|
@@ -38,7 +38,7 @@ function plugin(vikeConfig) {
|
|
|
38
38
|
...(0, commonConfig_js_1.commonConfig)(),
|
|
39
39
|
(0, index_js_2.importUserCode)(),
|
|
40
40
|
...(0, index_js_1.devConfig)(),
|
|
41
|
-
(0, buildConfig_js_1.buildConfig)(),
|
|
41
|
+
...(0, buildConfig_js_1.buildConfig)(),
|
|
42
42
|
(0, previewConfig_js_1.previewConfig)(),
|
|
43
43
|
...(0, autoFullBuild_js_1.autoFullBuild)(),
|
|
44
44
|
(0, packageJsonFile_js_1.packageJsonFile)(),
|
|
@@ -10,7 +10,7 @@ function baseUrls(configVike) {
|
|
|
10
10
|
return {
|
|
11
11
|
name: 'vike:baseUrls',
|
|
12
12
|
enforce: 'post',
|
|
13
|
-
config
|
|
13
|
+
async config(config) {
|
|
14
14
|
const bases = (0, resolveBase_js_1.resolveBaseFromUserConfig)(config, configVike);
|
|
15
15
|
baseServer = bases.baseServer;
|
|
16
16
|
baseAssets = bases.baseAssets;
|
|
@@ -49,10 +49,14 @@ async function copyAssets(filesToCopy, config) {
|
|
|
49
49
|
return;
|
|
50
50
|
(0, utils_js_1.assert)((0, fs_1.existsSync)(assetsDirServer));
|
|
51
51
|
const concurrencyLimit = (0, utils_js_1.pLimit)(10);
|
|
52
|
-
await Promise.all(filesToCopy.map((file) => concurrencyLimit(() =>
|
|
52
|
+
await Promise.all(filesToCopy.map((file) => concurrencyLimit(() =>
|
|
53
|
+
// TODO: move instead of copying
|
|
54
|
+
promises_1.default.cp(path_1.default.posix.join(outDirServer, file), path_1.default.posix.join(outDirClient, file), {
|
|
53
55
|
recursive: true
|
|
54
56
|
}))));
|
|
55
|
-
|
|
57
|
+
/* We cannot do that because, with some edge case Rollup settings (outputing JavaScript chunks and static assets to the same directoy), this removes JavaScript chunks, see https://github.com/vikejs/vike/issues/1154#issuecomment-1975762404
|
|
58
|
+
await fs.rm(assetsDirServer, { recursive: true })
|
|
59
|
+
*/
|
|
56
60
|
}
|
|
57
61
|
// Add serverManifest resources to clientManifest
|
|
58
62
|
function addServerAssets(clientManifest, serverManifest) {
|
|
@@ -18,6 +18,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
18
18
|
const fixServerAssets_js_1 = require("./buildConfig/fixServerAssets.js");
|
|
19
19
|
const index_js_1 = require("./importBuild/index.js");
|
|
20
20
|
const prependEntriesDir_js_1 = require("../../shared/prependEntriesDir.js");
|
|
21
|
+
const getFilePath_js_1 = require("../shared/getFilePath.js");
|
|
21
22
|
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
22
23
|
const importMetaUrl = `file://${__filename}`;
|
|
23
24
|
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
@@ -28,71 +29,81 @@ function buildConfig() {
|
|
|
28
29
|
let isSsrBuild;
|
|
29
30
|
let outDirs;
|
|
30
31
|
let config;
|
|
31
|
-
return
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
32
|
+
return [
|
|
33
|
+
{
|
|
34
|
+
name: 'vike:buildConfig:configResolved',
|
|
35
|
+
apply: 'build',
|
|
36
|
+
enforce: 'post',
|
|
37
|
+
configResolved: {
|
|
38
|
+
order: 'post',
|
|
39
|
+
async handler(config_) {
|
|
40
|
+
config = config_;
|
|
41
|
+
(0, utils_js_1.assertNodeEnv_build)();
|
|
42
|
+
assertRollupInput(config);
|
|
43
|
+
const entries = await getEntries(config);
|
|
44
|
+
(0, utils_js_1.assert)(Object.keys(entries).length > 0);
|
|
45
|
+
config.build.rollupOptions.input = (0, utils_js_1.injectRollupInputs)(entries, config);
|
|
46
|
+
addLogHook();
|
|
47
|
+
outDirs = (0, utils_js_1.getOutDirs)(config);
|
|
48
|
+
{
|
|
49
|
+
isServerAssetsFixEnabled = (0, fixServerAssets_js_1.fixServerAssets_isEnabled)() && (await (0, getVikeConfig_js_1.isV1Design)(config, false));
|
|
50
|
+
if (isServerAssetsFixEnabled) {
|
|
51
|
+
// https://github.com/vikejs/vike/issues/1339
|
|
52
|
+
config.build.ssrEmitAssets = true;
|
|
53
|
+
// Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934
|
|
54
|
+
config.build.cssMinify = 'esbuild';
|
|
55
|
+
}
|
|
53
56
|
}
|
|
54
57
|
}
|
|
58
|
+
},
|
|
59
|
+
config(config) {
|
|
60
|
+
(0, utils_js_1.assertNodeEnv_build)();
|
|
61
|
+
isSsrBuild = (0, utils_js_1.viteIsSSR)(config);
|
|
62
|
+
return {
|
|
63
|
+
build: {
|
|
64
|
+
outDir: (0, utils_js_1.resolveOutDir)(config),
|
|
65
|
+
manifest: manifestTempFile,
|
|
66
|
+
copyPublicDir: !isSsrBuild
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
buildStart() {
|
|
71
|
+
(0, utils_js_1.assertNodeEnv_build)();
|
|
55
72
|
}
|
|
56
73
|
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
await promises_1.default.
|
|
84
|
-
|
|
85
|
-
else {
|
|
86
|
-
const clientManifestMod = await (0, fixServerAssets_js_1.fixServerAssets)(config);
|
|
87
|
-
await promises_1.default.writeFile(assetsJsonFilePath, JSON.stringify(clientManifestMod, null, 2), 'utf-8');
|
|
74
|
+
{
|
|
75
|
+
name: 'vike:buildConfig:writeBundle',
|
|
76
|
+
apply: 'build',
|
|
77
|
+
// Make sure other writeBundle() hooks are called after this writeBundle() hook.
|
|
78
|
+
// - set_constant_ASSETS_MAP() needs to be called before dist/server/ code is executed.
|
|
79
|
+
// - For example, the writeBundle() hook of vite-plugin-vercel needs to be called after this writeBundle() hook, otherwise: https://github.com/vikejs/vike/issues/1527
|
|
80
|
+
enforce: 'pre',
|
|
81
|
+
writeBundle: {
|
|
82
|
+
order: 'pre',
|
|
83
|
+
sequential: true,
|
|
84
|
+
async handler(options, bundle) {
|
|
85
|
+
if (isSsrBuild) {
|
|
86
|
+
// Ideally we'd move dist/_temp_manifest.json to dist/server/client-assets.json instead of dist/assets.json
|
|
87
|
+
// - But we can't because there is no guarentee whether dist/server/ is generated before or after dist/client/ (generating dist/server/ after dist/client/ erases dist/server/client-assets.json)
|
|
88
|
+
// - We'll able to do so once we replace `$ vite build` with `$ vike build`
|
|
89
|
+
const assetsJsonFilePath = path_1.default.posix.join(outDirs.outDirRoot, 'assets.json');
|
|
90
|
+
const clientManifestFilePath = path_1.default.posix.join(outDirs.outDirClient, manifestTempFile);
|
|
91
|
+
const serverManifestFilePath = path_1.default.posix.join(outDirs.outDirServer, manifestTempFile);
|
|
92
|
+
if (!isServerAssetsFixEnabled) {
|
|
93
|
+
await promises_1.default.copyFile(clientManifestFilePath, assetsJsonFilePath);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
const clientManifestMod = await (0, fixServerAssets_js_1.fixServerAssets)(config);
|
|
97
|
+
await promises_1.default.writeFile(assetsJsonFilePath, JSON.stringify(clientManifestMod, null, 2), 'utf-8');
|
|
98
|
+
}
|
|
99
|
+
await promises_1.default.rm(clientManifestFilePath);
|
|
100
|
+
await promises_1.default.rm(serverManifestFilePath);
|
|
101
|
+
await (0, index_js_1.set_constant_ASSETS_MAP)(options, bundle);
|
|
88
102
|
}
|
|
89
|
-
await promises_1.default.rm(clientManifestFilePath);
|
|
90
|
-
await promises_1.default.rm(serverManifestFilePath);
|
|
91
|
-
await (0, index_js_1.set_constant_ASSETS_MAP)(options, bundle);
|
|
92
103
|
}
|
|
93
104
|
}
|
|
94
105
|
}
|
|
95
|
-
|
|
106
|
+
];
|
|
96
107
|
}
|
|
97
108
|
exports.buildConfig = buildConfig;
|
|
98
109
|
async function getEntries(config) {
|
|
@@ -195,18 +206,22 @@ async function getPageFileEntries(config, includeAssetsImportedByServer) {
|
|
|
195
206
|
return pageFileEntries;
|
|
196
207
|
}
|
|
197
208
|
function getEntryFromClientEntry(clientEntry, config, addExtractAssetsQuery) {
|
|
198
|
-
if (
|
|
209
|
+
if (!clientEntry.startsWith('/')) {
|
|
210
|
+
(0, utils_js_1.assertIsNpmPackageImport)(clientEntry);
|
|
199
211
|
const entryTarget = clientEntry;
|
|
200
212
|
const entryName = (0, prependEntriesDir_js_1.prependEntriesDir)(clientEntry);
|
|
201
213
|
return { entryName, entryTarget };
|
|
202
214
|
}
|
|
203
|
-
const
|
|
204
|
-
(0, utils_js_1.
|
|
205
|
-
(0,
|
|
206
|
-
|
|
215
|
+
const filePathAbsoluteUserRootDir = clientEntry;
|
|
216
|
+
(0, utils_js_1.assert)(filePathAbsoluteUserRootDir.startsWith('/'));
|
|
217
|
+
const filePath = (0, getFilePath_js_1.getFilePathResolved)({
|
|
218
|
+
filePathAbsoluteUserRootDir,
|
|
219
|
+
userRootDir: config.root
|
|
220
|
+
});
|
|
221
|
+
let entryTarget = filePath.filePathAbsoluteFilesystem;
|
|
207
222
|
if (addExtractAssetsQuery)
|
|
208
223
|
entryTarget = (0, extractAssetsQuery_js_1.extractAssetsAddQuery)(entryTarget);
|
|
209
|
-
let entryName =
|
|
224
|
+
let entryName = filePathAbsoluteUserRootDir;
|
|
210
225
|
if (addExtractAssetsQuery)
|
|
211
226
|
entryName = (0, extractAssetsQuery_js_1.extractAssetsAddQuery)(entryName);
|
|
212
227
|
entryName = (0, utils_js_1.removeFileExtention)(entryName);
|
|
@@ -6,8 +6,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.assertResolveAlias = void 0;
|
|
7
7
|
const utils_js_1 = require("../../utils.js");
|
|
8
8
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
9
|
-
//
|
|
9
|
+
// Recommend users to avoid un-distinguishable path aliases.
|
|
10
|
+
// There are a lot of libraries that don't or cannot follow that recommendation, for example:
|
|
11
|
+
// - Nx
|
|
12
|
+
// - Not sure why, but Nx seems to add a path alias for each monorepo package
|
|
13
|
+
// - https://github.com/vikejs/vike/discussions/1134
|
|
14
|
+
// - MUI
|
|
15
|
+
// - https://mui.com/material-ui/guides/minimizing-bundle-size/#how-to-use-custom-bundles
|
|
16
|
+
// - https://github.com/vikejs/vike/discussions/1549#discussioncomment-8789002
|
|
17
|
+
// - @preact/preset-vite
|
|
18
|
+
// - Aliases react imports
|
|
19
|
+
// - @vitejs/plugin-vue2
|
|
20
|
+
// - https://github.com/vikejs/vike/issues/1329
|
|
10
21
|
function assertResolveAlias(config) {
|
|
22
|
+
// TODO: re-implement warning https://github.com/vikejs/vike/issues/1567
|
|
23
|
+
return;
|
|
11
24
|
const aliases = getAliases(config);
|
|
12
25
|
const errPrefix = config.configFile || 'Your Vite configuration';
|
|
13
26
|
const errSuffix1 = 'see https://vike.dev/path-aliases#vite';
|
|
@@ -26,7 +26,7 @@ async function getConfigVikPromise(vikeConfig, config) {
|
|
|
26
26
|
const fromPluginOptions = (vikeConfig ?? {});
|
|
27
27
|
const fromViteConfig = (config.vike ?? {});
|
|
28
28
|
const configs = [fromPluginOptions, fromViteConfig];
|
|
29
|
-
const { globalVikeConfig: fromPlusConfigFile } = await (0, getVikeConfig_js_1.getVikeConfig)(config, (0, utils_js_1.isDev2)(config)
|
|
29
|
+
const { globalVikeConfig: fromPlusConfigFile } = await (0, getVikeConfig_js_1.getVikeConfig)(config, (0, utils_js_1.isDev2)(config));
|
|
30
30
|
configs.push(fromPlusConfigFile);
|
|
31
31
|
(0, assertVikeConfig_js_1.assertVikeConfig)(fromPlusConfigFile, ({ prop, errMsg }) => {
|
|
32
32
|
// TODO: add config file path ?
|
|
@@ -7,6 +7,8 @@ const getVikeConfig_js_1 = require("../importUserCode/v1-design/getVikeConfig.js
|
|
|
7
7
|
const getConfigValueSourcesNotOverriden_js_1 = require("../../shared/getConfigValueSourcesNotOverriden.js");
|
|
8
8
|
const buildConfig_js_1 = require("../buildConfig.js");
|
|
9
9
|
const virtualFileImportUserCode_js_1 = require("../../../shared/virtual-files/virtualFileImportUserCode.js");
|
|
10
|
+
const getFilePath_js_1 = require("../../shared/getFilePath.js");
|
|
11
|
+
const debug = (0, utils_js_1.createDebugger)('vike:optimizeDeps');
|
|
10
12
|
async function determineOptimizeDeps(config, isDev) {
|
|
11
13
|
const { pageConfigs } = await (0, getVikeConfig_js_1.getVikeConfig)(config, isDev);
|
|
12
14
|
const { entries, include } = await getPageDeps(config, pageConfigs, isDev);
|
|
@@ -23,7 +25,11 @@ async function determineOptimizeDeps(config, isDev) {
|
|
|
23
25
|
*/
|
|
24
26
|
config.optimizeDeps.include = [...include, ...normalizeInclude(config.optimizeDeps.include)];
|
|
25
27
|
config.optimizeDeps.entries = [...entries, ...normalizeEntries(config.optimizeDeps.entries)];
|
|
26
|
-
|
|
28
|
+
if (debug.isEnabled)
|
|
29
|
+
debug('config.optimizeDeps', {
|
|
30
|
+
'config.optimizeDeps.entries': config.optimizeDeps.entries,
|
|
31
|
+
'config.optimizeDeps.include': config.optimizeDeps.include
|
|
32
|
+
});
|
|
27
33
|
}
|
|
28
34
|
exports.determineOptimizeDeps = determineOptimizeDeps;
|
|
29
35
|
async function getPageDeps(config, pageConfigs, isDev) {
|
|
@@ -38,7 +44,7 @@ async function getPageDeps(config, pageConfigs, isDev) {
|
|
|
38
44
|
const { definedAt, configEnv } = configValueSource;
|
|
39
45
|
if (!configEnv.client)
|
|
40
46
|
return;
|
|
41
|
-
if (definedAt.
|
|
47
|
+
if (definedAt.filePathAbsoluteUserRootDir !== null) {
|
|
42
48
|
const { filePathAbsoluteFilesystem } = definedAt;
|
|
43
49
|
(0, utils_js_1.assert)(filePathAbsoluteFilesystem);
|
|
44
50
|
// Surprisingly Vite expects entries to be absolute paths
|
|
@@ -47,24 +53,10 @@ async function getPageDeps(config, pageConfigs, isDev) {
|
|
|
47
53
|
else {
|
|
48
54
|
// Adding definedAt.filePathAbsoluteFilesystem doesn't work for npm packages, I guess because of Vite's config.server.fs.allow
|
|
49
55
|
const { importPathAbsolute } = definedAt;
|
|
50
|
-
(0, utils_js_1.assert)(importPathAbsolute);
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if ((0, utils_js_1.isNpmPackageImport)(importPathAbsolute)) {
|
|
55
|
-
// isNpmPackageImport() returns false for a path alias like #root/renderer/onRenderClient
|
|
56
|
-
(0, utils_js_1.assert)(!importPathAbsolute.startsWith('#'));
|
|
57
|
-
include.push(importPathAbsolute);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
/* Path aliases, e.g.:
|
|
61
|
-
* ```js
|
|
62
|
-
* // /renderer/+config.js
|
|
63
|
-
* import onRenderClient from '#root/renderer/onRenderClient'
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
entries.push(importPathAbsolute);
|
|
67
|
-
}
|
|
56
|
+
(0, utils_js_1.assert)(importPathAbsolute); // Help TS
|
|
57
|
+
// Shouldn't be a path alias, as path aliases would need to be added to config.optimizeDeps.entries instead of config.optimizeDeps.include
|
|
58
|
+
(0, utils_js_1.assertIsNpmPackageImport)(importPathAbsolute);
|
|
59
|
+
include.push(importPathAbsolute);
|
|
68
60
|
}
|
|
69
61
|
});
|
|
70
62
|
});
|
|
@@ -72,9 +64,12 @@ async function getPageDeps(config, pageConfigs, isDev) {
|
|
|
72
64
|
// V0.4 design
|
|
73
65
|
{
|
|
74
66
|
const pageFiles = await (0, findPageFiles_js_1.findPageFiles)(config, ['.page', '.page.client'], isDev);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
67
|
+
const userRootDir = config.root;
|
|
68
|
+
pageFiles.forEach((filePathAbsoluteUserRootDir) => {
|
|
69
|
+
const entry = (0, getFilePath_js_1.getFilePathResolved)({ filePathAbsoluteUserRootDir, userRootDir });
|
|
70
|
+
const { filePathAbsoluteFilesystem } = entry;
|
|
71
|
+
(0, utils_js_1.assert)(filePathAbsoluteFilesystem);
|
|
72
|
+
entries.push(filePathAbsoluteFilesystem);
|
|
78
73
|
});
|
|
79
74
|
}
|
|
80
75
|
entries = (0, utils_js_1.unique)(entries);
|
|
@@ -4,6 +4,7 @@ exports.applyEnvVar = exports.envVarsPlugin = void 0;
|
|
|
4
4
|
const vite_1 = require("vite");
|
|
5
5
|
const utils_js_1 = require("../utils.js");
|
|
6
6
|
const rollupSourceMap_js_1 = require("../shared/rollupSourceMap.js");
|
|
7
|
+
const getFilePath_js_1 = require("../shared/getFilePath.js");
|
|
7
8
|
function envVarsPlugin() {
|
|
8
9
|
let envsAll;
|
|
9
10
|
let config;
|
|
@@ -45,10 +46,10 @@ function envVarsPlugin() {
|
|
|
45
46
|
if (isPrivate && isClientSide) {
|
|
46
47
|
if (!code.includes(envStatement))
|
|
47
48
|
return;
|
|
48
|
-
const
|
|
49
|
+
const modulePath = (0, getFilePath_js_1.getModuleFilePath)(id, config);
|
|
49
50
|
const errMsgAddendum = isBuild ? '' : ' (Vike will prevent your app from building for production)';
|
|
50
51
|
const keyPublic = `${publicPrefix}${envName}`;
|
|
51
|
-
const errMsg = `${envStatement} is used in client-side file ${
|
|
52
|
+
const errMsg = `${envStatement} is used in client-side file ${modulePath} which means that the environment variable ${envName} will be included in client-side bundles and, therefore, ${envName} will be publicly exposed which can be a security leak${errMsgAddendum}. Use ${envStatement} only in server-side files, or rename ${envName} to ${keyPublic}, see https://vike.dev/env`;
|
|
52
53
|
if (isBuild) {
|
|
53
54
|
(0, utils_js_1.assertUsage)(false, errMsg);
|
|
54
55
|
}
|
|
@@ -120,12 +120,6 @@ function extractAssetsPlugin() {
|
|
|
120
120
|
{
|
|
121
121
|
name: 'vike:extractAssets-3',
|
|
122
122
|
apply: 'build',
|
|
123
|
-
async configResolved(config_) {
|
|
124
|
-
configVike = await (0, getConfigVike_js_1.getConfigVike)(config_);
|
|
125
|
-
config = config_;
|
|
126
|
-
vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config, false);
|
|
127
|
-
isServerAssetsFixEnabled = (0, fixServerAssets_js_1.fixServerAssets_isEnabled)() && (await (0, getVikeConfig_js_1.isV1Design)(config, false));
|
|
128
|
-
},
|
|
129
123
|
load(id) {
|
|
130
124
|
if (!(0, utils_js_1.isVirtualFileId)(id))
|
|
131
125
|
return undefined;
|
|
@@ -142,9 +136,15 @@ function extractAssetsPlugin() {
|
|
|
142
136
|
},
|
|
143
137
|
{
|
|
144
138
|
name: 'vike:extractAssets-4',
|
|
145
|
-
configResolved(
|
|
146
|
-
|
|
147
|
-
|
|
139
|
+
async configResolved(config_) {
|
|
140
|
+
configVike = await (0, getConfigVike_js_1.getConfigVike)(config_);
|
|
141
|
+
config = config_;
|
|
142
|
+
vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config, false);
|
|
143
|
+
isServerAssetsFixEnabled = (0, fixServerAssets_js_1.fixServerAssets_isEnabled)() && (await (0, getVikeConfig_js_1.isV1Design)(config, false));
|
|
144
|
+
if (!isServerAssetsFixEnabled) {
|
|
145
|
+
// https://github.com/vikejs/vike/issues/1060
|
|
146
|
+
(0, utils_js_1.assertUsage)(!config.plugins.find((p) => p.name === 'vite-tsconfig-paths'), 'vite-tsconfig-paths not supported, remove it and use vite.config.js#resolve.alias instead');
|
|
147
|
+
}
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
];
|
|
@@ -8,6 +8,7 @@ const utils_js_1 = require("../utils.js");
|
|
|
8
8
|
const extractAssetsPlugin_js_1 = require("./extractAssetsPlugin.js");
|
|
9
9
|
const extractExportNamesPlugin_js_1 = require("./extractExportNamesPlugin.js");
|
|
10
10
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
11
|
+
const getFilePath_js_1 = require("../shared/getFilePath.js");
|
|
11
12
|
function fileEnv() {
|
|
12
13
|
let config;
|
|
13
14
|
let isDev = false;
|
|
@@ -44,11 +45,13 @@ function fileEnv() {
|
|
|
44
45
|
// resolved is null when import path is erroneous and doesn't actually point to a file
|
|
45
46
|
if (!resolved)
|
|
46
47
|
return;
|
|
47
|
-
const
|
|
48
|
+
const moduleId = resolved.id;
|
|
49
|
+
const modulePath = moduleId.split('?')[0];
|
|
48
50
|
// `.server.js` and `.client.js` should only apply to user files
|
|
49
51
|
if (modulePath.includes('/node_modules/'))
|
|
50
52
|
return;
|
|
51
53
|
// TODO/v1-release: remove
|
|
54
|
+
// - I don't remember exactly, but I think I've added `TODO/v1-release: remove` because I vaguely remember that we can remove this after we remove the 0.4 design.
|
|
52
55
|
if (modulePath.endsWith('.css'))
|
|
53
56
|
return;
|
|
54
57
|
const isServerSide = options?.ssr;
|
|
@@ -60,7 +63,7 @@ function fileEnv() {
|
|
|
60
63
|
return;
|
|
61
64
|
// Show error message
|
|
62
65
|
let errMsg;
|
|
63
|
-
let modulePathPretty = (0,
|
|
66
|
+
let modulePathPretty = (0, getFilePath_js_1.getModuleFilePath)(moduleId, config);
|
|
64
67
|
modulePathPretty = modulePathPretty.replaceAll(suffix, picocolors_1.default.bold(suffix));
|
|
65
68
|
errMsg = `${(0, utils_js_1.capitalizeFirstLetter)(envExpect)}-only module ${modulePathPretty} (https://vike.dev/file-env) imported on the ${envActual}-side`;
|
|
66
69
|
if (importer &&
|
|
@@ -68,7 +71,7 @@ function fileEnv() {
|
|
|
68
71
|
!importer.includes('virtual:vike:') &&
|
|
69
72
|
// I don't know why and who sets importer to '<stdin>' (I guess Vite?)
|
|
70
73
|
importer !== '<stdin>') {
|
|
71
|
-
const importerPath = (0,
|
|
74
|
+
const importerPath = (0, getFilePath_js_1.getModuleFilePath)(importer, config);
|
|
72
75
|
errMsg += ` by ${importerPath}`;
|
|
73
76
|
}
|
|
74
77
|
if (isDev) {
|
|
@@ -14,6 +14,7 @@ const virtualFileImportUserCode_js_1 = require("../../../shared/virtual-files/vi
|
|
|
14
14
|
const getVikeConfig_js_1 = require("./v1-design/getVikeConfig.js");
|
|
15
15
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
16
16
|
const loggerNotProd_js_1 = require("../../shared/loggerNotProd.js");
|
|
17
|
+
const getFilePath_js_1 = require("../../shared/getFilePath.js");
|
|
17
18
|
function importUserCode() {
|
|
18
19
|
let config;
|
|
19
20
|
let configVike;
|
|
@@ -124,8 +125,11 @@ function isVikeConfigModule(filePathAbsoluteFilesystem) {
|
|
|
124
125
|
}
|
|
125
126
|
function reloadConfig(filePath, config, op) {
|
|
126
127
|
{
|
|
127
|
-
const
|
|
128
|
-
|
|
128
|
+
const { filePathToShowToUserResolved } = (0, getFilePath_js_1.getFilePathResolved)({
|
|
129
|
+
filePathAbsoluteFilesystem: filePath,
|
|
130
|
+
userRootDir: config.root
|
|
131
|
+
});
|
|
132
|
+
const msg = `${op} ${picocolors_1.default.dim(filePathToShowToUserResolved)}`;
|
|
129
133
|
(0, loggerNotProd_js_1.logConfigInfo)(msg, 'info');
|
|
130
134
|
}
|
|
131
135
|
(0, getVikeConfig_js_1.reloadVikeConfig)(config.root, (0, utils_js_1.getOutDirs)(config).outDirRoot);
|
|
@@ -105,7 +105,6 @@ const configDefinitionsBuiltInGlobal = {
|
|
|
105
105
|
prerender: {
|
|
106
106
|
env: { config: true }
|
|
107
107
|
},
|
|
108
|
-
extensions: { env: { config: true } },
|
|
109
108
|
disableAutoFullBuild: { env: { config: true } },
|
|
110
109
|
includeAssetsImportedByServer: { env: { config: true } },
|
|
111
110
|
baseAssets: { env: { config: true } },
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -11,9 +11,9 @@ const child_process_1 = require("child_process");
|
|
|
11
11
|
const util_1 = require("util");
|
|
12
12
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
13
13
|
const execA = (0, util_1.promisify)(child_process_1.exec);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
15
|
+
(0, utils_js_1.assertIsSingleModuleInstance)('crawlPlusFiles.ts');
|
|
16
|
+
let gitIsNotUsable = false;
|
|
17
17
|
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
18
18
|
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
19
19
|
(0, utils_js_1.assertPosixPath)(outDirAbsoluteFilesystem);
|
|
@@ -48,15 +48,15 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
|
48
48
|
const plusFiles = files.map((p) => {
|
|
49
49
|
p = (0, utils_js_1.toPosixPath)(p);
|
|
50
50
|
(0, utils_js_1.assert)(!p.startsWith(userRootDir));
|
|
51
|
-
const
|
|
52
|
-
return {
|
|
51
|
+
const filePathAbsoluteUserRootDir = path_1.default.posix.join('/', p);
|
|
52
|
+
return { filePathAbsoluteUserRootDir };
|
|
53
53
|
});
|
|
54
54
|
return plusFiles;
|
|
55
55
|
}
|
|
56
56
|
exports.crawlPlusFiles = crawlPlusFiles;
|
|
57
57
|
// Same as fastGlob() but using `$ git ls-files`
|
|
58
58
|
async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
59
|
-
if (
|
|
59
|
+
if (gitIsNotUsable)
|
|
60
60
|
return null;
|
|
61
61
|
const ignoreAsPatterns = getIgnoreAsPatterns(outDirRelativeFromUserRootDir);
|
|
62
62
|
const ignoreAsFilterFn = getIgnoreAsFilterFn(outDirRelativeFromUserRootDir);
|
|
@@ -74,14 +74,14 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
74
74
|
;
|
|
75
75
|
[files, filesDeleted] = await Promise.all([
|
|
76
76
|
// Main command
|
|
77
|
-
|
|
77
|
+
runCmd1(cmd, userRootDir),
|
|
78
78
|
// Get tracked by deleted files
|
|
79
|
-
|
|
79
|
+
runCmd1('git ls-files --deleted', userRootDir)
|
|
80
80
|
]);
|
|
81
81
|
}
|
|
82
82
|
catch (err) {
|
|
83
|
-
if (await
|
|
84
|
-
|
|
83
|
+
if (await isGitNotUsable(userRootDir)) {
|
|
84
|
+
gitIsNotUsable = true;
|
|
85
85
|
return null;
|
|
86
86
|
}
|
|
87
87
|
throw err;
|
|
@@ -125,24 +125,53 @@ function getIgnoreAsFilterFn(outDirRelativeFromUserRootDir) {
|
|
|
125
125
|
!file.includes('.telefunc.') &&
|
|
126
126
|
(outDirRelativeFromUserRootDir === null || !file.startsWith(`${outDirRelativeFromUserRootDir}/`));
|
|
127
127
|
}
|
|
128
|
-
// Whether Git is installed and whether
|
|
129
|
-
async function
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
res = await
|
|
128
|
+
// Whether Git is installed and whether we can use it
|
|
129
|
+
async function isGitNotUsable(userRootDir) {
|
|
130
|
+
// Check Git version
|
|
131
|
+
{
|
|
132
|
+
const res = await runCmd2('git --version', userRootDir);
|
|
133
|
+
if ('err' in res)
|
|
134
|
+
return true;
|
|
135
|
+
let { stdout, stderr } = res;
|
|
136
|
+
(0, utils_js_1.assert)(stderr === '');
|
|
137
|
+
const prefix = 'git version ';
|
|
138
|
+
(0, utils_js_1.assert)(stdout.startsWith(prefix));
|
|
139
|
+
const gitVersion = stdout.slice(prefix.length);
|
|
140
|
+
// - Works with Git 2.43.1 but also (most certainly) with earlier versions.
|
|
141
|
+
// - We didn't bother test which is the earliest verision that works.
|
|
142
|
+
// - Git 2.32.0 doesn't seem to work: https://github.com/vikejs/vike/discussions/1549
|
|
143
|
+
// - Maybe it's because of StackBlitz: looking at the release notes, Git 2.32.0 should be working.
|
|
144
|
+
if (!(0, utils_js_1.isVersionOrAbove)(gitVersion, '2.43.1'))
|
|
145
|
+
return true;
|
|
133
146
|
}
|
|
134
|
-
|
|
135
|
-
|
|
147
|
+
// Is userRootDir inside a Git repository?
|
|
148
|
+
{
|
|
149
|
+
const res = await runCmd2('git rev-parse --is-inside-work-tree', userRootDir);
|
|
150
|
+
if ('err' in res)
|
|
151
|
+
return true;
|
|
152
|
+
let { stdout, stderr } = res;
|
|
153
|
+
(0, utils_js_1.assert)(stderr === '');
|
|
154
|
+
(0, utils_js_1.assert)(stdout === 'true');
|
|
155
|
+
return false;
|
|
136
156
|
}
|
|
137
|
-
const { stdout, stderr } = res;
|
|
138
|
-
(0, utils_js_1.assert)(stderr.toString().trim() === '');
|
|
139
|
-
(0, utils_js_1.assert)(stdout.toString().trim() === 'true');
|
|
140
|
-
return false;
|
|
141
157
|
}
|
|
142
|
-
async function
|
|
143
|
-
const
|
|
158
|
+
async function runCmd1(cmd, cwd) {
|
|
159
|
+
const { stdout } = await execA(cmd, { cwd });
|
|
144
160
|
/* Not always true: https://github.com/vikejs/vike/issues/1440#issuecomment-1892831303
|
|
145
161
|
assert(res.stderr === '')
|
|
146
162
|
*/
|
|
147
|
-
return
|
|
163
|
+
return stdout.toString().split('\n').filter(Boolean);
|
|
164
|
+
}
|
|
165
|
+
async function runCmd2(cmd, cwd) {
|
|
166
|
+
let res;
|
|
167
|
+
try {
|
|
168
|
+
res = await execA(cmd, { cwd });
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
return { err };
|
|
172
|
+
}
|
|
173
|
+
let { stdout, stderr } = res;
|
|
174
|
+
stdout = stdout.toString().trim();
|
|
175
|
+
stderr = stderr.toString().trim();
|
|
176
|
+
return { stdout, stderr };
|
|
148
177
|
}
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js
CHANGED
|
@@ -10,10 +10,10 @@ const utils_js_1 = require("../../../../utils.js");
|
|
|
10
10
|
*/
|
|
11
11
|
function getLocationId(
|
|
12
12
|
// We always determine `locationId` from a real user-land file: the `locationId` for Vike extensions is the `locationId` of the the user's `+config.js` that extends the Vike extension.
|
|
13
|
-
|
|
14
|
-
(0, utils_js_1.assertPosixPath)(
|
|
15
|
-
(0, utils_js_1.assert)(
|
|
16
|
-
const locationId = removeFilename(
|
|
13
|
+
filePathAbsoluteUserRootDir) {
|
|
14
|
+
(0, utils_js_1.assertPosixPath)(filePathAbsoluteUserRootDir);
|
|
15
|
+
(0, utils_js_1.assert)(filePathAbsoluteUserRootDir.startsWith('/'));
|
|
16
|
+
const locationId = removeFilename(filePathAbsoluteUserRootDir);
|
|
17
17
|
assertLocationId(locationId);
|
|
18
18
|
return locationId;
|
|
19
19
|
}
|
|
@@ -96,8 +96,8 @@ function removeDirectories(somePath, removeDirs) {
|
|
|
96
96
|
somePath = '/';
|
|
97
97
|
return somePath;
|
|
98
98
|
}
|
|
99
|
-
function removeFilename(
|
|
100
|
-
const filePathParts =
|
|
99
|
+
function removeFilename(filePathAbsoluteUserRootDir) {
|
|
100
|
+
const filePathParts = filePathAbsoluteUserRootDir.split('/');
|
|
101
101
|
{
|
|
102
102
|
const filename = filePathParts.slice(-1)[0];
|
|
103
103
|
(0, utils_js_1.assert)(filename.includes('.'));
|