vike 0.4.187 → 0.4.188-commit-373ae21

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.
Files changed (32) hide show
  1. package/dist/cjs/node/plugin/index.js +3 -1
  2. package/dist/cjs/node/plugin/plugins/distFileNames.js +36 -7
  3. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +1 -1
  4. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +1 -1
  5. package/dist/cjs/node/plugin/plugins/workaroundCssModuleHmr.js +16 -0
  6. package/dist/cjs/node/plugin/shared/getFilePath.js +9 -9
  7. package/dist/cjs/node/plugin/utils.js +1 -1
  8. package/dist/cjs/node/prerender/runPrerender.js +1 -1
  9. package/dist/cjs/node/prerender/utils.js +1 -1
  10. package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
  11. package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +60 -0
  12. package/dist/esm/node/plugin/index.js +3 -1
  13. package/dist/esm/node/plugin/plugins/distFileNames.js +37 -8
  14. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +2 -2
  15. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +2 -2
  16. package/dist/esm/node/plugin/plugins/workaroundCssModuleHmr.d.ts +3 -0
  17. package/dist/esm/node/plugin/plugins/workaroundCssModuleHmr.js +13 -0
  18. package/dist/esm/node/plugin/shared/getFilePath.js +10 -10
  19. package/dist/esm/node/plugin/utils.d.ts +1 -1
  20. package/dist/esm/node/plugin/utils.js +1 -1
  21. package/dist/esm/node/prerender/runPrerender.js +2 -2
  22. package/dist/esm/node/prerender/utils.d.ts +1 -1
  23. package/dist/esm/node/prerender/utils.js +1 -1
  24. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  25. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  26. package/dist/esm/utils/isFilePathAbsoluteFilesystem.d.ts +14 -0
  27. package/dist/esm/utils/isFilePathAbsoluteFilesystem.js +54 -0
  28. package/dist/esm/utils/projectInfo.d.ts +1 -1
  29. package/package.json +1 -1
  30. package/dist/cjs/utils/assertPathFilesystemAbsolute.js +0 -39
  31. package/dist/esm/utils/assertPathFilesystemAbsolute.d.ts +0 -6
  32. package/dist/esm/utils/assertPathFilesystemAbsolute.js +0 -33
@@ -30,6 +30,7 @@ const picocolors_1 = __importDefault(require("@brillout/picocolors"));
30
30
  const fileEnv_js_1 = require("./plugins/fileEnv.js");
31
31
  const getPageAssets_js_1 = require("../runtime/renderPage/getPageAssets.js");
32
32
  const resolveClientEntriesDev_js_1 = require("./resolveClientEntriesDev.js");
33
+ const workaroundCssModuleHmr_js_1 = require("./plugins/workaroundCssModuleHmr.js");
33
34
  (0, utils_js_2.assertNodeEnv_onVikePluginLoad)();
34
35
  (0, utils_js_2.markEnvAsVikePluginLoaded)();
35
36
  assertViteVersion();
@@ -54,7 +55,8 @@ function plugin(vikeConfig) {
54
55
  ...(0, index_js_4.importBuild)(),
55
56
  (0, baseUrls_js_1.baseUrls)(vikeConfig),
56
57
  (0, envVars_js_1.envVarsPlugin)(),
57
- (0, fileEnv_js_1.fileEnv)()
58
+ (0, fileEnv_js_1.fileEnv)(),
59
+ (0, workaroundCssModuleHmr_js_1.workaroundCssModuleHmr)()
58
60
  ];
59
61
  return plugins;
60
62
  }
@@ -53,13 +53,39 @@ function distFileNames() {
53
53
  }
54
54
  // Disable CSS bundling to workaround https://github.com/vikejs/vike/issues/1815
55
55
  if (id.endsWith('.css')) {
56
- const filePath = (0, getFilePath_js_1.getModuleFilePathAbsolute)(id, config);
57
- const fileName = filePath.split('/').pop().split('.').slice(0, -1).join('.');
58
- (0, getFilePath_js_1.assertModuleId)(id);
59
- // Don't remove `?` queries, because in principle each `id` should belong to a unique bundle.
60
- const idStable = path_1.default.posix.relative(config.root, id);
61
- const fileHash = crypto_1.default.createHash('md5').update(idStable).digest('hex').slice(0, 8);
62
- return `${fileName}-${fileHash}`;
56
+ if ((0, utils_js_1.isFilePathAbsolute)(id)) {
57
+ (0, utils_js_1.assertPosixPath)(id);
58
+ (0, getFilePath_js_1.assertModuleId)(id);
59
+ let name;
60
+ const isNodeModules = id.match(/node_modules\/([^\/]+)\/(?!.*node_modules)/);
61
+ if (isNodeModules) {
62
+ name = isNodeModules[1];
63
+ }
64
+ else {
65
+ const filePath = (0, getFilePath_js_1.getModuleFilePathAbsolute)(id, config);
66
+ name = filePath;
67
+ name = name.split('.').slice(0, -1).join('.'); // remove file extension
68
+ name = name.split('/').join('_');
69
+ }
70
+ // Make fileHash the same between local development and CI
71
+ const idStable = path_1.default.posix.relative(config.root, id);
72
+ // Don't remove `?` queries because each `id` should belong to a unique bundle.
73
+ const hash = getIdHash(idStable);
74
+ return `${name}-${hash}`;
75
+ }
76
+ else {
77
+ let name;
78
+ const isVirtualModule = id.match(/virtual:([^:]+):/);
79
+ if (!isVirtualModule) {
80
+ name = 'style';
81
+ }
82
+ else {
83
+ name = isVirtualModule[1];
84
+ (0, utils_js_1.assert)(name);
85
+ }
86
+ const hash = getIdHash(id);
87
+ return `${name}-${hash}`;
88
+ }
63
89
  }
64
90
  };
65
91
  }
@@ -68,6 +94,9 @@ function distFileNames() {
68
94
  };
69
95
  }
70
96
  exports.distFileNames = distFileNames;
97
+ function getIdHash(id) {
98
+ return crypto_1.default.createHash('md5').update(id).digest('hex').slice(0, 8);
99
+ }
71
100
  function getAssetFileName(assetInfo, config) {
72
101
  const assetsDir = (0, getAssetsDir_js_1.getAssetsDir)(config);
73
102
  const dir = assetsDir + '/static';
@@ -37,7 +37,7 @@ function resolvePointerImport(pointerImportData, importerFilePath, userRootDir)
37
37
  // - An npm package import
38
38
  // - importPath cannot be a path alias (since esbuild resolves path aliases, see transpileAndExecuteFile.ts)
39
39
  (0, utils_js_1.assertPosixPath)(importPath);
40
- if (importPath.startsWith('.') || (0, utils_js_1.isPathFilesystemAbsolute)(importPath)) {
40
+ if (importPath.startsWith('.') || (0, utils_js_1.isFilePathAbsolute)(importPath)) {
41
41
  if (importPath.startsWith('.')) {
42
42
  (0, utils_js_1.assert)(importPath.startsWith('./') || importPath.startsWith('../'));
43
43
  }
@@ -123,7 +123,7 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
123
123
  // isNpmPackageImport(str, { cannotBePathAlias: true })
124
124
  // assertIsNpmPackageImport()
125
125
  // ```
126
- (0, utils_js_1.assertPathFilesystemAbsolute)(importPathResolved);
126
+ (0, utils_js_1.assertFilePathAbsoluteFilesystem)(importPathResolved);
127
127
  // vike-{react,vue,solid} follow the convention that their config export resolves to a file named +config.js
128
128
  // - This is temporary, see comment below.
129
129
  const isVikeExtensionConfigImport = importPathResolved.endsWith('+config.js');
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.workaroundCssModuleHmr = void 0;
4
+ function workaroundCssModuleHmr() {
5
+ return {
6
+ name: 'vike:workaroundCssModuleHmr',
7
+ handleHotUpdate(ctx) {
8
+ // prevent full reload due to non self-accepting css module.
9
+ // here only "?direct" module should be filtered out as it doesn't have a parent module.
10
+ if (ctx.file.includes('module.css')) {
11
+ return ctx.modules.filter((m) => !m.id?.includes('?direct'));
12
+ }
13
+ }
14
+ };
15
+ }
16
+ exports.workaroundCssModuleHmr = workaroundCssModuleHmr;
@@ -19,7 +19,7 @@ function getFilePathResolved(args) {
19
19
  filePathAbsoluteFilesystem = getFilePathAbsoluteUserFilesystem({ filePathAbsoluteUserRootDir, userRootDir });
20
20
  }
21
21
  (0, utils_js_1.assert)(filePathAbsoluteFilesystem);
22
- (0, utils_js_1.assertPathFilesystemAbsolute)(filePathAbsoluteFilesystem);
22
+ (0, utils_js_1.assertFilePathAbsoluteFilesystem)(filePathAbsoluteFilesystem);
23
23
  const filePathToShowToUserResolved = filePathAbsoluteUserRootDir || filePathAbsoluteFilesystem;
24
24
  (0, utils_js_1.assert)(filePathToShowToUserResolved);
25
25
  (0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
@@ -70,9 +70,9 @@ exports.getFilePathUnresolved = getFilePathUnresolved;
70
70
  function getFilePathAbsoluteUserFilesystem({ filePathAbsoluteUserRootDir, userRootDir }) {
71
71
  (0, utils_js_1.assertPosixPath)(filePathAbsoluteUserRootDir);
72
72
  (0, utils_js_1.assertPosixPath)(userRootDir);
73
- (0, utils_js_1.assertPathFilesystemAbsolute)(userRootDir);
73
+ (0, utils_js_1.assertFilePathAbsoluteFilesystem)(userRootDir);
74
74
  const filePathAbsoluteFilesystem = path_1.default.posix.join(userRootDir, filePathAbsoluteUserRootDir);
75
- (0, utils_js_1.assertPathFilesystemAbsolute)(userRootDir);
75
+ (0, utils_js_1.assertFilePathAbsoluteFilesystem)(userRootDir);
76
76
  return filePathAbsoluteFilesystem;
77
77
  }
78
78
  function getFilePathAbsoluteUserRootDir({ filePathAbsoluteFilesystem, userRootDir }) {
@@ -86,8 +86,8 @@ exports.getFilePathAbsoluteUserRootDir = getFilePathAbsoluteUserRootDir;
86
86
  function getFilePathRelative({ filePathAbsoluteFilesystem, userRootDir }) {
87
87
  (0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
88
88
  (0, utils_js_1.assertPosixPath)(userRootDir);
89
- (0, utils_js_1.assertPathFilesystemAbsolute)(filePathAbsoluteFilesystem);
90
- (0, utils_js_1.assertPathFilesystemAbsolute)(userRootDir);
89
+ (0, utils_js_1.assertFilePathAbsoluteFilesystem)(filePathAbsoluteFilesystem);
90
+ (0, utils_js_1.assertFilePathAbsoluteFilesystem)(userRootDir);
91
91
  const filePathRelativeUserRootDir = path_1.default.posix.relative(userRootDir, filePathAbsoluteFilesystem);
92
92
  if (!filePathAbsoluteFilesystem.startsWith(userRootDir)) {
93
93
  (0, utils_js_1.assert)(filePathRelativeUserRootDir.startsWith('../'));
@@ -122,9 +122,9 @@ function getModuleFilePath(moduleId, config) {
122
122
  const userRootDir = config.root;
123
123
  assertModuleId(moduleId);
124
124
  (0, utils_js_1.assertPosixPath)(userRootDir);
125
- (0, utils_js_1.assertPathFilesystemAbsolute)(userRootDir);
125
+ (0, utils_js_1.assertFilePathAbsoluteFilesystem)(userRootDir);
126
126
  const filePathAbsoluteFilesystem = cleanModuleId(moduleId);
127
- (0, utils_js_1.assertPathFilesystemAbsolute)(filePathAbsoluteFilesystem);
127
+ (0, utils_js_1.assertFilePathAbsoluteFilesystem)(filePathAbsoluteFilesystem);
128
128
  const { filePathAbsoluteUserRootDir, filePathRelativeUserRootDir } = getFilePathRelative({
129
129
  filePathAbsoluteFilesystem,
130
130
  userRootDir
@@ -133,14 +133,14 @@ function getModuleFilePath(moduleId, config) {
133
133
  }
134
134
  function assertModuleId(moduleId) {
135
135
  (0, utils_js_1.assertPosixPath)(moduleId);
136
- (0, utils_js_1.assertPathFilesystemAbsolute)(moduleId); // Can moduleId be something else than the filesystem absolute path?
136
+ (0, utils_js_1.assertFilePathAbsoluteFilesystem)(moduleId); // Can moduleId be something else than the filesystem absolute path?
137
137
  }
138
138
  exports.assertModuleId = assertModuleId;
139
139
  function getFilePathToShowToUserFromUnkown(
140
140
  // We don't have any guarentee about filePath, e.g. about whether is filePathAbsoluteFilesystem or filePathAbsoluteUserRootDir
141
141
  filePathUnkown, userRootDir) {
142
142
  (0, utils_js_1.assertPosixPath)(userRootDir);
143
- (0, utils_js_1.assertPathFilesystemAbsolute)(userRootDir);
143
+ (0, utils_js_1.assertFilePathAbsoluteFilesystem)(userRootDir);
144
144
  filePathUnkown = cleanFilePathUnkown(filePathUnkown);
145
145
  if (!filePathUnkown.startsWith(userRootDir)) {
146
146
  return filePathUnkown;
@@ -40,6 +40,6 @@ __exportStar(require("../../utils/injectRollupInputs.js"), exports);
40
40
  __exportStar(require("../../utils/humanizeTime.js"), exports);
41
41
  __exportStar(require("../../utils/pLimit.js"), exports);
42
42
  __exportStar(require("../../utils/assertVersion.js"), exports);
43
- __exportStar(require("../../utils/assertPathFilesystemAbsolute.js"), exports);
43
+ __exportStar(require("../../utils/isFilePathAbsoluteFilesystem.js"), exports);
44
44
  __exportStar(require("../../utils/isArray.js"), exports);
45
45
  __exportStar(require("../../utils/PROJECT_VERSION.js"), exports);
@@ -105,7 +105,7 @@ async function runPrerender(options, manuallyTriggered) {
105
105
  }
106
106
  const { partial = false, noExtraDir = false, parallel = true } = prerenderConfig || {};
107
107
  const concurrencyLimit = (0, utils_js_1.pLimit)(parallel === false || parallel === 0 ? 1 : parallel === true || parallel === undefined ? (0, os_1.cpus)().length : parallel);
108
- (0, utils_js_1.assertPathFilesystemAbsolute)(outDirRoot); // Needed for loadImportBuild(outDir) of @brillout/vite-plugin-server-entry
108
+ (0, utils_js_1.assertFilePathAbsoluteFilesystem)(outDirRoot); // Needed for loadImportBuild(outDir) of @brillout/vite-plugin-server-entry
109
109
  await (0, globalContext_js_1.initGlobalContext)(true, outDirRoot);
110
110
  const renderContext = await (0, renderPageAlreadyRouted_js_1.getRenderContext)();
111
111
  renderContext.pageFilesAll.forEach(assertExportNames);
@@ -29,6 +29,6 @@ __exportStar(require("../../utils/urlToFile.js"), exports);
29
29
  __exportStar(require("../../utils/isPlainObject.js"), exports);
30
30
  __exportStar(require("../../utils/assertNodeEnv.js"), exports);
31
31
  __exportStar(require("../../utils/pLimit.js"), exports);
32
- __exportStar(require("../../utils/assertPathFilesystemAbsolute.js"), exports);
32
+ __exportStar(require("../../utils/isFilePathAbsoluteFilesystem.js"), exports);
33
33
  __exportStar(require("../../utils/isArray.js"), exports);
34
34
  __exportStar(require("../../utils/changeEnumerable.js"), exports);
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PROJECT_VERSION = void 0;
4
4
  // Automatically updated by @brillout/release-me
5
- exports.PROJECT_VERSION = '0.4.187';
5
+ exports.PROJECT_VERSION = '0.4.188-commit-373ae21';
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isFilePathAbsolute = exports.assertFilePathAbsoluteFilesystem = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const assert_js_1 = require("./assert.js");
9
+ const filesystemPathHandling_js_1 = require("./filesystemPathHandling.js");
10
+ /**
11
+ * Asserts that `filePath` is an absolute file path starting from the filesystem root.
12
+ *
13
+ * It isn't reliable for Linux users, but that's okay because the assertion will eventually fail on windows.
14
+ */
15
+ function assertFilePathAbsoluteFilesystem(filePath) {
16
+ // The assert is "eventually reliable":
17
+ // - For Windows users, the assert is correct.
18
+ // - For Linux users assertFilePathAbsoluteFilesystem() will erroneously succeed if `p` is a path absolute from the user root dir.
19
+ // - But that's okay because the assertion will eventually fail for Windows users.
20
+ (0, assert_js_1.assert)(isFilePathAbsoluteFilesystem(filePath));
21
+ (0, filesystemPathHandling_js_1.assertPosixPath)(filePath);
22
+ }
23
+ exports.assertFilePathAbsoluteFilesystem = assertFilePathAbsoluteFilesystem;
24
+ /**
25
+ * Whether `filePath` is an absolute file path starting from the filesystem root.
26
+ *
27
+ * Isn't reliable for Linux users: it returns `true` for an absolute path starting from the user root dir.
28
+ */
29
+ function isFilePathAbsoluteFilesystem(filePath) {
30
+ (0, assert_js_1.assert)(!filePath.startsWith('/@fs/'));
31
+ if (process.platform !== 'win32') {
32
+ // - For linux users, there doesn't seem to be a reliable way to distinguish between:
33
+ // - File path absolute starting from filesystem root, e.g. /home/rom/code/my-app/pages/about/+Page.js
34
+ // - File path absolute starting from user root dir (Vite's `config.root`), e.g. /pages/about/+Page.js
35
+ // - Checking whether `p` starts with the first directory of process.cwd() (or `userRootDir`) can be erroneous, most notably when using docker: https://github.com/vikejs/vike/issues/703
36
+ // - Using require.resolve() would be a solution but probably too slow?
37
+ return filePath.startsWith('/');
38
+ }
39
+ else {
40
+ const yes = path_1.default.win32.isAbsolute(filePath);
41
+ // Ensure isFilePathAbsoluteFilesystem() returns `false` if path is absolute starting from the user root dir (see comments above).
42
+ if (yes)
43
+ (0, assert_js_1.assert)(!filePath.startsWith('/'));
44
+ return yes;
45
+ }
46
+ }
47
+ /**
48
+ * Whether `filePath` is an absolute file path.
49
+ *
50
+ * Returns `true` regardless whether it starts from the user root dir or filesystem root.
51
+ */
52
+ function isFilePathAbsolute(filePath) {
53
+ (0, assert_js_1.assert)(!filePath.startsWith('/@fs/'));
54
+ // Absolute path starting from the user root dir.
55
+ if (filePath.startsWith('/'))
56
+ return true;
57
+ // Seems to be reliable: https://nodejs.org/api/path.html#pathisabsolutepath
58
+ return path_1.default.isAbsolute(filePath);
59
+ }
60
+ exports.isFilePathAbsolute = isFilePathAbsolute;
@@ -26,6 +26,7 @@ import pc from '@brillout/picocolors';
26
26
  import { fileEnv } from './plugins/fileEnv.js';
27
27
  import { setResolveClientEntriesDev } from '../runtime/renderPage/getPageAssets.js';
28
28
  import { resolveClientEntriesDev } from './resolveClientEntriesDev.js';
29
+ import { workaroundCssModuleHmr } from './plugins/workaroundCssModuleHmr.js';
29
30
  assertNodeEnv_onVikePluginLoad();
30
31
  markEnvAsVikePluginLoaded();
31
32
  assertViteVersion();
@@ -50,7 +51,8 @@ function plugin(vikeConfig) {
50
51
  ...importBuild(),
51
52
  baseUrls(vikeConfig),
52
53
  envVarsPlugin(),
53
- fileEnv()
54
+ fileEnv(),
55
+ workaroundCssModuleHmr()
54
56
  ];
55
57
  return plugins;
56
58
  }
@@ -2,7 +2,7 @@ export { distFileNames };
2
2
  // Attempt to preserve file structure of `.page.js` files:
3
3
  // - https://github.com/vikejs/vike/commit/11a4c49e5403aa7c37c8020c462b499425b41854
4
4
  // - Blocker: https://github.com/rollup/rollup/issues/4724
5
- import { assertPosixPath, assert, assertUsage, isArray, isCallable } from '../utils.js';
5
+ import { assertPosixPath, assert, assertUsage, isArray, isCallable, isFilePathAbsolute } from '../utils.js';
6
6
  import path from 'path';
7
7
  import crypto from 'crypto';
8
8
  import { getAssetsDir } from '../shared/getAssetsDir.js';
@@ -48,13 +48,39 @@ function distFileNames() {
48
48
  }
49
49
  // Disable CSS bundling to workaround https://github.com/vikejs/vike/issues/1815
50
50
  if (id.endsWith('.css')) {
51
- const filePath = getModuleFilePathAbsolute(id, config);
52
- const fileName = filePath.split('/').pop().split('.').slice(0, -1).join('.');
53
- assertModuleId(id);
54
- // Don't remove `?` queries, because in principle each `id` should belong to a unique bundle.
55
- const idStable = path.posix.relative(config.root, id);
56
- const fileHash = crypto.createHash('md5').update(idStable).digest('hex').slice(0, 8);
57
- return `${fileName}-${fileHash}`;
51
+ if (isFilePathAbsolute(id)) {
52
+ assertPosixPath(id);
53
+ assertModuleId(id);
54
+ let name;
55
+ const isNodeModules = id.match(/node_modules\/([^\/]+)\/(?!.*node_modules)/);
56
+ if (isNodeModules) {
57
+ name = isNodeModules[1];
58
+ }
59
+ else {
60
+ const filePath = getModuleFilePathAbsolute(id, config);
61
+ name = filePath;
62
+ name = name.split('.').slice(0, -1).join('.'); // remove file extension
63
+ name = name.split('/').join('_');
64
+ }
65
+ // Make fileHash the same between local development and CI
66
+ const idStable = path.posix.relative(config.root, id);
67
+ // Don't remove `?` queries because each `id` should belong to a unique bundle.
68
+ const hash = getIdHash(idStable);
69
+ return `${name}-${hash}`;
70
+ }
71
+ else {
72
+ let name;
73
+ const isVirtualModule = id.match(/virtual:([^:]+):/);
74
+ if (!isVirtualModule) {
75
+ name = 'style';
76
+ }
77
+ else {
78
+ name = isVirtualModule[1];
79
+ assert(name);
80
+ }
81
+ const hash = getIdHash(id);
82
+ return `${name}-${hash}`;
83
+ }
58
84
  }
59
85
  };
60
86
  }
@@ -62,6 +88,9 @@ function distFileNames() {
62
88
  }
63
89
  };
64
90
  }
91
+ function getIdHash(id) {
92
+ return crypto.createHash('md5').update(id).digest('hex').slice(0, 8);
93
+ }
65
94
  function getAssetFileName(assetInfo, config) {
66
95
  const assetsDir = getAssetsDir(config);
67
96
  const dir = assetsDir + '/static';
@@ -2,7 +2,7 @@ export { resolvePointerImportOfConfig };
2
2
  export { resolvePointerImport };
3
3
  export { clearFilesEnvMap };
4
4
  import pc from '@brillout/picocolors';
5
- import { assert, assertIsNpmPackageImport, assertPosixPath, assertUsage, deepEqual, isPathFilesystemAbsolute, requireResolve } from '../../../../utils.js';
5
+ import { assert, assertIsNpmPackageImport, assertPosixPath, assertUsage, deepEqual, isFilePathAbsolute, requireResolve } from '../../../../utils.js';
6
6
  import { parsePointerImportData } from './transformFileImports.js';
7
7
  import path from 'path';
8
8
  import { getFilePathAbsoluteUserRootDir, getFilePathResolved, getFilePathUnresolved } from '../../../../shared/getFilePath.js';
@@ -33,7 +33,7 @@ function resolvePointerImport(pointerImportData, importerFilePath, userRootDir)
33
33
  // - An npm package import
34
34
  // - importPath cannot be a path alias (since esbuild resolves path aliases, see transpileAndExecuteFile.ts)
35
35
  assertPosixPath(importPath);
36
- if (importPath.startsWith('.') || isPathFilesystemAbsolute(importPath)) {
36
+ if (importPath.startsWith('.') || isFilePathAbsolute(importPath)) {
37
37
  if (importPath.startsWith('.')) {
38
38
  assert(importPath.startsWith('./') || importPath.startsWith('../'));
39
39
  }
@@ -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, assertPathFilesystemAbsolute, assertIsNpmPackageImport } from '../../../../utils.js';
10
+ import { assertPosixPath, getRandomId, assertIsNotProductionRuntime, assert, assertWarning, isObject, toPosixPath, assertUsage, isJavaScriptFile, createDebugger, assertFilePathAbsoluteFilesystem, assertIsNpmPackageImport } 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';
@@ -120,7 +120,7 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
120
120
  // isNpmPackageImport(str, { cannotBePathAlias: true })
121
121
  // assertIsNpmPackageImport()
122
122
  // ```
123
- assertPathFilesystemAbsolute(importPathResolved);
123
+ assertFilePathAbsoluteFilesystem(importPathResolved);
124
124
  // vike-{react,vue,solid} follow the convention that their config export resolves to a file named +config.js
125
125
  // - This is temporary, see comment below.
126
126
  const isVikeExtensionConfigImport = importPathResolved.endsWith('+config.js');
@@ -0,0 +1,3 @@
1
+ export { workaroundCssModuleHmr };
2
+ import type { Plugin } from 'vite';
3
+ declare function workaroundCssModuleHmr(): Plugin;
@@ -0,0 +1,13 @@
1
+ export { workaroundCssModuleHmr };
2
+ function workaroundCssModuleHmr() {
3
+ return {
4
+ name: 'vike:workaroundCssModuleHmr',
5
+ handleHotUpdate(ctx) {
6
+ // prevent full reload due to non self-accepting css module.
7
+ // here only "?direct" module should be filtered out as it doesn't have a parent module.
8
+ if (ctx.file.includes('module.css')) {
9
+ return ctx.modules.filter((m) => !m.id?.includes('?direct'));
10
+ }
11
+ }
12
+ };
13
+ }
@@ -7,7 +7,7 @@ export { getModuleFilePathRelative };
7
7
  export { cleanFilePathUnkown };
8
8
  export { assertModuleId };
9
9
  import path from 'path';
10
- import { assert, assertIsNpmPackageImport, assertPathFilesystemAbsolute, assertPosixPath, toPosixPath } from '../utils.js';
10
+ import { assert, assertIsNpmPackageImport, assertFilePathAbsoluteFilesystem, assertPosixPath, toPosixPath } from '../utils.js';
11
11
  function getFilePathResolved(args) {
12
12
  const { userRootDir } = args;
13
13
  let filePathAbsoluteFilesystem;
@@ -21,7 +21,7 @@ function getFilePathResolved(args) {
21
21
  filePathAbsoluteFilesystem = getFilePathAbsoluteUserFilesystem({ filePathAbsoluteUserRootDir, userRootDir });
22
22
  }
23
23
  assert(filePathAbsoluteFilesystem);
24
- assertPathFilesystemAbsolute(filePathAbsoluteFilesystem);
24
+ assertFilePathAbsoluteFilesystem(filePathAbsoluteFilesystem);
25
25
  const filePathToShowToUserResolved = filePathAbsoluteUserRootDir || filePathAbsoluteFilesystem;
26
26
  assert(filePathToShowToUserResolved);
27
27
  assertPosixPath(filePathAbsoluteFilesystem);
@@ -70,9 +70,9 @@ function getFilePathUnresolved(args) {
70
70
  function getFilePathAbsoluteUserFilesystem({ filePathAbsoluteUserRootDir, userRootDir }) {
71
71
  assertPosixPath(filePathAbsoluteUserRootDir);
72
72
  assertPosixPath(userRootDir);
73
- assertPathFilesystemAbsolute(userRootDir);
73
+ assertFilePathAbsoluteFilesystem(userRootDir);
74
74
  const filePathAbsoluteFilesystem = path.posix.join(userRootDir, filePathAbsoluteUserRootDir);
75
- assertPathFilesystemAbsolute(userRootDir);
75
+ assertFilePathAbsoluteFilesystem(userRootDir);
76
76
  return filePathAbsoluteFilesystem;
77
77
  }
78
78
  function getFilePathAbsoluteUserRootDir({ filePathAbsoluteFilesystem, userRootDir }) {
@@ -85,8 +85,8 @@ function getFilePathAbsoluteUserRootDir({ filePathAbsoluteFilesystem, userRootDi
85
85
  function getFilePathRelative({ filePathAbsoluteFilesystem, userRootDir }) {
86
86
  assertPosixPath(filePathAbsoluteFilesystem);
87
87
  assertPosixPath(userRootDir);
88
- assertPathFilesystemAbsolute(filePathAbsoluteFilesystem);
89
- assertPathFilesystemAbsolute(userRootDir);
88
+ assertFilePathAbsoluteFilesystem(filePathAbsoluteFilesystem);
89
+ assertFilePathAbsoluteFilesystem(userRootDir);
90
90
  const filePathRelativeUserRootDir = path.posix.relative(userRootDir, filePathAbsoluteFilesystem);
91
91
  if (!filePathAbsoluteFilesystem.startsWith(userRootDir)) {
92
92
  assert(filePathRelativeUserRootDir.startsWith('../'));
@@ -119,9 +119,9 @@ function getModuleFilePath(moduleId, config) {
119
119
  const userRootDir = config.root;
120
120
  assertModuleId(moduleId);
121
121
  assertPosixPath(userRootDir);
122
- assertPathFilesystemAbsolute(userRootDir);
122
+ assertFilePathAbsoluteFilesystem(userRootDir);
123
123
  const filePathAbsoluteFilesystem = cleanModuleId(moduleId);
124
- assertPathFilesystemAbsolute(filePathAbsoluteFilesystem);
124
+ assertFilePathAbsoluteFilesystem(filePathAbsoluteFilesystem);
125
125
  const { filePathAbsoluteUserRootDir, filePathRelativeUserRootDir } = getFilePathRelative({
126
126
  filePathAbsoluteFilesystem,
127
127
  userRootDir
@@ -130,13 +130,13 @@ function getModuleFilePath(moduleId, config) {
130
130
  }
131
131
  function assertModuleId(moduleId) {
132
132
  assertPosixPath(moduleId);
133
- assertPathFilesystemAbsolute(moduleId); // Can moduleId be something else than the filesystem absolute path?
133
+ assertFilePathAbsoluteFilesystem(moduleId); // Can moduleId be something else than the filesystem absolute path?
134
134
  }
135
135
  function getFilePathToShowToUserFromUnkown(
136
136
  // We don't have any guarentee about filePath, e.g. about whether is filePathAbsoluteFilesystem or filePathAbsoluteUserRootDir
137
137
  filePathUnkown, userRootDir) {
138
138
  assertPosixPath(userRootDir);
139
- assertPathFilesystemAbsolute(userRootDir);
139
+ assertFilePathAbsoluteFilesystem(userRootDir);
140
140
  filePathUnkown = cleanFilePathUnkown(filePathUnkown);
141
141
  if (!filePathUnkown.startsWith(userRootDir)) {
142
142
  return filePathUnkown;
@@ -18,6 +18,6 @@ export * from '../../utils/injectRollupInputs.js';
18
18
  export * from '../../utils/humanizeTime.js';
19
19
  export * from '../../utils/pLimit.js';
20
20
  export * from '../../utils/assertVersion.js';
21
- export * from '../../utils/assertPathFilesystemAbsolute.js';
21
+ export * from '../../utils/isFilePathAbsoluteFilesystem.js';
22
22
  export * from '../../utils/isArray.js';
23
23
  export * from '../../utils/PROJECT_VERSION.js';
@@ -24,6 +24,6 @@ export * from '../../utils/injectRollupInputs.js';
24
24
  export * from '../../utils/humanizeTime.js';
25
25
  export * from '../../utils/pLimit.js';
26
26
  export * from '../../utils/assertVersion.js';
27
- export * from '../../utils/assertPathFilesystemAbsolute.js';
27
+ export * from '../../utils/isFilePathAbsoluteFilesystem.js';
28
28
  export * from '../../utils/isArray.js';
29
29
  export * from '../../utils/PROJECT_VERSION.js';
@@ -5,7 +5,7 @@ export { runPrerender_forceExit };
5
5
  import '../runtime/page-files/setup.js';
6
6
  import path from 'path';
7
7
  import { route } from '../../shared/route/index.js';
8
- import { assert, assertUsage, assertWarning, hasProp, projectInfo, objectAssign, isObjectWithKeys, isCallable, getOutDirs, isPropertyGetter, assertPosixPath, urlToFile, isPlainObject, handleNodeEnv_prerender, pLimit, assertPathFilesystemAbsolute, isArray, changeEnumerable } from './utils.js';
8
+ import { assert, assertUsage, assertWarning, hasProp, projectInfo, objectAssign, isObjectWithKeys, isCallable, getOutDirs, isPropertyGetter, assertPosixPath, urlToFile, isPlainObject, handleNodeEnv_prerender, pLimit, assertFilePathAbsoluteFilesystem, isArray, changeEnumerable } from './utils.js';
9
9
  import { prerenderPage, prerender404Page, getRenderContext, getPageContextInitEnhanced } from '../runtime/renderPage/renderPageAlreadyRouted.js';
10
10
  import pc from '@brillout/picocolors';
11
11
  import { cpus } from 'os';
@@ -77,7 +77,7 @@ async function runPrerender(options, manuallyTriggered) {
77
77
  }
78
78
  const { partial = false, noExtraDir = false, parallel = true } = prerenderConfig || {};
79
79
  const concurrencyLimit = pLimit(parallel === false || parallel === 0 ? 1 : parallel === true || parallel === undefined ? cpus().length : parallel);
80
- assertPathFilesystemAbsolute(outDirRoot); // Needed for loadImportBuild(outDir) of @brillout/vite-plugin-server-entry
80
+ assertFilePathAbsoluteFilesystem(outDirRoot); // Needed for loadImportBuild(outDir) of @brillout/vite-plugin-server-entry
81
81
  await initGlobalContext(true, outDirRoot);
82
82
  const renderContext = await getRenderContext();
83
83
  renderContext.pageFilesAll.forEach(assertExportNames);
@@ -11,6 +11,6 @@ export * from '../../utils/urlToFile.js';
11
11
  export * from '../../utils/isPlainObject.js';
12
12
  export * from '../../utils/assertNodeEnv.js';
13
13
  export * from '../../utils/pLimit.js';
14
- export * from '../../utils/assertPathFilesystemAbsolute.js';
14
+ export * from '../../utils/isFilePathAbsoluteFilesystem.js';
15
15
  export * from '../../utils/isArray.js';
16
16
  export * from '../../utils/changeEnumerable.js';
@@ -13,6 +13,6 @@ export * from '../../utils/urlToFile.js';
13
13
  export * from '../../utils/isPlainObject.js';
14
14
  export * from '../../utils/assertNodeEnv.js';
15
15
  export * from '../../utils/pLimit.js';
16
- export * from '../../utils/assertPathFilesystemAbsolute.js';
16
+ export * from '../../utils/isFilePathAbsoluteFilesystem.js';
17
17
  export * from '../../utils/isArray.js';
18
18
  export * from '../../utils/changeEnumerable.js';
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.187";
1
+ export declare const PROJECT_VERSION: "0.4.188-commit-373ae21";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.187';
2
+ export const PROJECT_VERSION = '0.4.188-commit-373ae21';
@@ -0,0 +1,14 @@
1
+ export { assertFilePathAbsoluteFilesystem };
2
+ export { isFilePathAbsolute };
3
+ /**
4
+ * Asserts that `filePath` is an absolute file path starting from the filesystem root.
5
+ *
6
+ * It isn't reliable for Linux users, but that's okay because the assertion will eventually fail on windows.
7
+ */
8
+ declare function assertFilePathAbsoluteFilesystem(filePath: string): void;
9
+ /**
10
+ * Whether `filePath` is an absolute file path.
11
+ *
12
+ * Returns `true` regardless whether it starts from the user root dir or filesystem root.
13
+ */
14
+ declare function isFilePathAbsolute(filePath: string): boolean;
@@ -0,0 +1,54 @@
1
+ export { assertFilePathAbsoluteFilesystem };
2
+ export { isFilePathAbsolute };
3
+ import path from 'path';
4
+ import { assert } from './assert.js';
5
+ import { assertPosixPath } from './filesystemPathHandling.js';
6
+ /**
7
+ * Asserts that `filePath` is an absolute file path starting from the filesystem root.
8
+ *
9
+ * It isn't reliable for Linux users, but that's okay because the assertion will eventually fail on windows.
10
+ */
11
+ function assertFilePathAbsoluteFilesystem(filePath) {
12
+ // The assert is "eventually reliable":
13
+ // - For Windows users, the assert is correct.
14
+ // - For Linux users assertFilePathAbsoluteFilesystem() will erroneously succeed if `p` is a path absolute from the user root dir.
15
+ // - But that's okay because the assertion will eventually fail for Windows users.
16
+ assert(isFilePathAbsoluteFilesystem(filePath));
17
+ assertPosixPath(filePath);
18
+ }
19
+ /**
20
+ * Whether `filePath` is an absolute file path starting from the filesystem root.
21
+ *
22
+ * Isn't reliable for Linux users: it returns `true` for an absolute path starting from the user root dir.
23
+ */
24
+ function isFilePathAbsoluteFilesystem(filePath) {
25
+ assert(!filePath.startsWith('/@fs/'));
26
+ if (process.platform !== 'win32') {
27
+ // - For linux users, there doesn't seem to be a reliable way to distinguish between:
28
+ // - File path absolute starting from filesystem root, e.g. /home/rom/code/my-app/pages/about/+Page.js
29
+ // - File path absolute starting from user root dir (Vite's `config.root`), e.g. /pages/about/+Page.js
30
+ // - Checking whether `p` starts with the first directory of process.cwd() (or `userRootDir`) can be erroneous, most notably when using docker: https://github.com/vikejs/vike/issues/703
31
+ // - Using require.resolve() would be a solution but probably too slow?
32
+ return filePath.startsWith('/');
33
+ }
34
+ else {
35
+ const yes = path.win32.isAbsolute(filePath);
36
+ // Ensure isFilePathAbsoluteFilesystem() returns `false` if path is absolute starting from the user root dir (see comments above).
37
+ if (yes)
38
+ assert(!filePath.startsWith('/'));
39
+ return yes;
40
+ }
41
+ }
42
+ /**
43
+ * Whether `filePath` is an absolute file path.
44
+ *
45
+ * Returns `true` regardless whether it starts from the user root dir or filesystem root.
46
+ */
47
+ function isFilePathAbsolute(filePath) {
48
+ assert(!filePath.startsWith('/@fs/'));
49
+ // Absolute path starting from the user root dir.
50
+ if (filePath.startsWith('/'))
51
+ return true;
52
+ // Seems to be reliable: https://nodejs.org/api/path.html#pathisabsolutepath
53
+ return path.isAbsolute(filePath);
54
+ }
@@ -1,4 +1,4 @@
1
1
  export declare const projectInfo: {
2
2
  projectName: "Vike";
3
- projectVersion: "0.4.187";
3
+ projectVersion: "0.4.188-commit-373ae21";
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.187",
3
+ "version": "0.4.188-commit-373ae21",
4
4
  "scripts": {
5
5
  "dev": "tsc --watch",
6
6
  "build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
@@ -1,39 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isPathFilesystemAbsolute = exports.assertPathFilesystemAbsolute = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const assert_js_1 = require("./assert.js");
9
- const filesystemPathHandling_js_1 = require("./filesystemPathHandling.js");
10
- /** Assert path is absolute starting from the filesystem root. */
11
- function assertPathFilesystemAbsolute(p) {
12
- // The assert is "eventually reliable":
13
- // - For Windows users, the assert is correct.
14
- // - For Linux users assertPathFilesystemAbsolute() will erroneously succeed if `p` is a path absolute from the user root dir.
15
- // - But that's okay because the assertion will eventually fail for Windows users.
16
- (0, assert_js_1.assert)(isPathFilesystemAbsolute(p));
17
- }
18
- exports.assertPathFilesystemAbsolute = assertPathFilesystemAbsolute;
19
- /** Whether path is absolute starting from the filesystem root. Isn't reliable for Linux users: isPathFilesystemAbsolute() returns `true` for paths absolute from the user root dir. */
20
- function isPathFilesystemAbsolute(p) {
21
- (0, filesystemPathHandling_js_1.assertPosixPath)(p);
22
- (0, assert_js_1.assert)(!p.startsWith('/@fs/'));
23
- if (process.platform !== 'win32') {
24
- // - For linux users, there doesn't seem to be a reliable way to distinguish between:
25
- // - File path absolute starting from filesystem root, e.g. /home/rom/code/my-app/pages/about/+Page.js
26
- // - File path absolute starting from user root dir (Vite's `config.root`), e.g. /pages/about/+Page.js
27
- // - Checking whether `p` starts with the first directory of process.cwd() (or `userRootDir`) can be erroneous, most notably when using docker: https://github.com/vikejs/vike/issues/703
28
- // - Using require.resolve() would be a solution but probably too slow?
29
- return p.startsWith('/');
30
- }
31
- else {
32
- const yes = path_1.default.win32.isAbsolute(p);
33
- // Ensure isPathFilesystemAbsolute() returns `false` if path is absolute starting from the user root dir (see comments above).
34
- if (yes)
35
- (0, assert_js_1.assert)(!p.startsWith('/'));
36
- return yes;
37
- }
38
- }
39
- exports.isPathFilesystemAbsolute = isPathFilesystemAbsolute;
@@ -1,6 +0,0 @@
1
- export { assertPathFilesystemAbsolute };
2
- export { isPathFilesystemAbsolute };
3
- /** Assert path is absolute starting from the filesystem root. */
4
- declare function assertPathFilesystemAbsolute(p: string): void;
5
- /** Whether path is absolute starting from the filesystem root. Isn't reliable for Linux users: isPathFilesystemAbsolute() returns `true` for paths absolute from the user root dir. */
6
- declare function isPathFilesystemAbsolute(p: string): boolean;
@@ -1,33 +0,0 @@
1
- export { assertPathFilesystemAbsolute };
2
- export { isPathFilesystemAbsolute };
3
- import path from 'path';
4
- import { assert } from './assert.js';
5
- import { assertPosixPath } from './filesystemPathHandling.js';
6
- /** Assert path is absolute starting from the filesystem root. */
7
- function assertPathFilesystemAbsolute(p) {
8
- // The assert is "eventually reliable":
9
- // - For Windows users, the assert is correct.
10
- // - For Linux users assertPathFilesystemAbsolute() will erroneously succeed if `p` is a path absolute from the user root dir.
11
- // - But that's okay because the assertion will eventually fail for Windows users.
12
- assert(isPathFilesystemAbsolute(p));
13
- }
14
- /** Whether path is absolute starting from the filesystem root. Isn't reliable for Linux users: isPathFilesystemAbsolute() returns `true` for paths absolute from the user root dir. */
15
- function isPathFilesystemAbsolute(p) {
16
- assertPosixPath(p);
17
- assert(!p.startsWith('/@fs/'));
18
- if (process.platform !== 'win32') {
19
- // - For linux users, there doesn't seem to be a reliable way to distinguish between:
20
- // - File path absolute starting from filesystem root, e.g. /home/rom/code/my-app/pages/about/+Page.js
21
- // - File path absolute starting from user root dir (Vite's `config.root`), e.g. /pages/about/+Page.js
22
- // - Checking whether `p` starts with the first directory of process.cwd() (or `userRootDir`) can be erroneous, most notably when using docker: https://github.com/vikejs/vike/issues/703
23
- // - Using require.resolve() would be a solution but probably too slow?
24
- return p.startsWith('/');
25
- }
26
- else {
27
- const yes = path.win32.isAbsolute(p);
28
- // Ensure isPathFilesystemAbsolute() returns `false` if path is absolute starting from the user root dir (see comments above).
29
- if (yes)
30
- assert(!p.startsWith('/'));
31
- return yes;
32
- }
33
- }