vike 0.4.239-commit-9dcde6d → 0.4.239-commit-86a0513

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,22 @@
1
1
  export { pluginNonRunnableDev };
2
- import { createViteRPC, assertIsNotProductionRuntime, requireResolveDistFile, isRunnableDevEnvironment, assert, escapeRegex, isDevCheck, } from '../utils.js';
2
+ import { createViteRPC, assertIsNotProductionRuntime, isRunnableDevEnvironment, assert, isDevCheck } from '../utils.js';
3
3
  import { retrievePageAssetsDev } from '../../runtime/renderPage/getPageAssets/retrievePageAssetsDev.js';
4
4
  import { getViteConfigRuntime } from '../shared/getViteConfigRuntime.js';
5
5
  import { getMagicString } from '../shared/getMagicString.js';
6
6
  assertIsNotProductionRuntime();
7
- const distFileIsNonRunnableDev = requireResolveDistFile('dist/esm/utils/isNonRunnableDev.js');
8
- const distFileGlobalContext = requireResolveDistFile('dist/esm/node/runtime/globalContext.js');
7
+ /* We cannot use [`filter.id`](https://rolldown.rs/plugins/hook-filters) because Vite's optimizeDeps bundles the package `vike` into node_modules/.vite/deps_ssr/chunk-WBC5FHD7.js
8
+ const distFileIsNonRunnableDev = requireResolveDistFile('dist/esm/utils/isNonRunnableDev.js')
9
+ const distFileGlobalContext = requireResolveDistFile('dist/esm/node/runtime/globalContext.js')
9
10
  const filterRolldown = {
10
- id: {
11
- include: [distFileIsNonRunnableDev, distFileGlobalContext].map((filePath) => new RegExp(`^${escapeRegex(filePath)}($|${escapeRegex('?')}.*)`)),
12
- },
13
- };
14
- const filterFunction = (id) => {
15
- const idWithoutQuery = getIdWithoutQuery(id);
16
- return idWithoutQuery === distFileIsNonRunnableDev || idWithoutQuery === distFileGlobalContext;
17
- };
11
+ id: {
12
+ include: [distFileIsNonRunnableDev, distFileGlobalContext].map(
13
+ (filePath) => new RegExp(`^${escapeRegex(filePath)}($|${escapeRegex('?')}.*)`),
14
+ ),
15
+ },
16
+ }
17
+ */
18
+ const __VIKE__DYNAMIC_IMPORT = '__VIKE__DYNAMIC_IMPORT';
19
+ const __VIKE__IS_NON_RUNNABLE_DEV = '__VIKE__IS_NON_RUNNABLE_DEV';
18
20
  function getViteRpcFunctions(viteDevServer) {
19
21
  return {
20
22
  async transformIndexHtmlRPC(html) {
@@ -32,7 +34,7 @@ function pluginNonRunnableDev() {
32
34
  let config;
33
35
  return [
34
36
  {
35
- name: 'vike:pluginNonRunnableDev',
37
+ name: 'vike:pluginNonRunnableDev:1',
36
38
  apply: (_, configEnv) => isDevCheck(configEnv),
37
39
  configureServer: {
38
40
  handler(viteDevServer) {
@@ -45,26 +47,39 @@ function pluginNonRunnableDev() {
45
47
  },
46
48
  },
47
49
  transform: {
48
- filter: filterRolldown,
50
+ filter: {
51
+ code: {
52
+ include: __VIKE__IS_NON_RUNNABLE_DEV,
53
+ },
54
+ },
55
+ handler(code, id) {
56
+ assert(config._isDev);
57
+ if (isRunnableDevEnvironment(this.environment))
58
+ return;
59
+ const { magicString, getMagicStringResult } = getMagicString(code, id);
60
+ magicString.replaceAll(__VIKE__IS_NON_RUNNABLE_DEV, JSON.stringify(true));
61
+ return getMagicStringResult();
62
+ },
63
+ },
64
+ },
65
+ {
66
+ name: 'vike:pluginNonRunnableDev:2',
67
+ apply: (_, configEnv) => isDevCheck(configEnv),
68
+ transform: {
69
+ filter: {
70
+ code: {
71
+ include: __VIKE__DYNAMIC_IMPORT,
72
+ },
73
+ },
49
74
  handler(code, id) {
50
75
  assert(config._isDev);
51
- assert(filterFunction(id));
52
- const idWithoutQuery = getIdWithoutQuery(id);
53
76
  if (isRunnableDevEnvironment(this.environment))
54
77
  return;
55
78
  const { magicString, getMagicStringResult } = getMagicString(code, id);
56
- if (idWithoutQuery === distFileIsNonRunnableDev) {
57
- magicString.replaceAll('__VIKE__IS_NON_RUNNABLE_DEV', JSON.stringify(true));
58
- }
59
- if (idWithoutQuery === distFileGlobalContext) {
60
- magicString.replaceAll('__VIKE__DYNAMIC_IMPORT', 'import');
61
- }
79
+ magicString.replaceAll(__VIKE__DYNAMIC_IMPORT, 'import');
62
80
  return getMagicStringResult();
63
81
  },
64
82
  },
65
83
  },
66
84
  ];
67
85
  }
68
- function getIdWithoutQuery(id) {
69
- return id.split('?')[0];
70
- }
@@ -4,6 +4,9 @@ import MagicString from 'magic-string';
4
4
  function getMagicString(code, id) {
5
5
  const magicString = new MagicString(code);
6
6
  const getMagicStringResult = () => {
7
+ /* TODO/now uncomment + dedupe
8
+ if (!magicString.hasChanged()) return undefined
9
+ */
7
10
  return {
8
11
  code: magicString.toString(),
9
12
  map: magicString.generateMap({ hires: true, source: id }),
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.239-commit-9dcde6d";
1
+ export declare const PROJECT_VERSION: "0.4.239-commit-86a0513";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.239-commit-9dcde6d';
2
+ export const PROJECT_VERSION = '0.4.239-commit-86a0513';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.239-commit-9dcde6d",
3
+ "version": "0.4.239-commit-86a0513",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {
@@ -117,7 +117,7 @@
117
117
  "@brillout/json-serializer": "^0.5.20",
118
118
  "@brillout/picocolors": "^1.0.26",
119
119
  "@brillout/require-shim": "^0.1.2",
120
- "@brillout/vite-plugin-server-entry": "^0.7.14",
120
+ "@brillout/vite-plugin-server-entry": "0.7.14-commit-9aaa9d4",
121
121
  "acorn": "^8.0.0",
122
122
  "cac": "^6.0.0",
123
123
  "es-module-lexer": "^1.0.0",