vike 0.4.249-commit-ec50591 → 0.4.249-commit-92f1383

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.
@@ -11,6 +11,7 @@ const constantsIsClientSide = [
11
11
  ];
12
12
  // - See https://vike.dev/pageContext#narrowing-down
13
13
  // - We cannot use [`define`](https://vite.dev/config/shared-options.html#define) because of https://github.com/rolldown/rolldown/issues/4300
14
+ // filterRolldown
14
15
  const skipNodeModules = '/node_modules/';
15
16
  const skipIrrelevant = 'Context.isClientSide';
16
17
  assert(constantsIsClientSide.every((constant) => constant.endsWith(skipIrrelevant)));
@@ -6,8 +6,4 @@ import type { StaticReplace } from './applyStaticReplace.js';
6
6
  * except for call.match.function array which is OR logic.
7
7
  * Between staticReplace entries it's OR logic.
8
8
  */
9
- declare function buildFilterRolldown(staticReplaceList: StaticReplace[]): {
10
- code: {
11
- include: RegExp;
12
- };
13
- } | null;
9
+ declare function buildFilterRolldown(staticReplaceList: StaticReplace[]): RegExp | null;
@@ -61,12 +61,7 @@ function buildFilterRolldown(staticReplaceList) {
61
61
  if (rulePatterns.length === 0)
62
62
  return null;
63
63
  // Create a regex that matches if any rule pattern matches (OR between staticReplace entries)
64
- const regex = new RegExp(rulePatterns.join('|'));
65
- return {
66
- code: {
67
- include: regex,
68
- },
69
- };
64
+ return new RegExp(rulePatterns.join('|'), 's');
70
65
  }
71
66
  /**
72
67
  * Extract import strings from function patterns
@@ -5,11 +5,29 @@ import { applyStaticReplace } from './pluginStaticReplace/applyStaticReplace.js'
5
5
  import { buildFilterRolldown } from './pluginStaticReplace/buildFilterRolldown.js';
6
6
  function pluginStaticReplace(vikeConfig) {
7
7
  let config;
8
+ // staticReplaceList
8
9
  const staticReplaceList = getStaticReplaceList(vikeConfig);
9
10
  if (staticReplaceList.length === 0)
10
11
  return [];
11
- const filterRolldown = buildFilterRolldown(staticReplaceList);
12
- assert(filterRolldown);
12
+ // filterRolldown
13
+ const skipNodeModules = '/node_modules/';
14
+ const include = buildFilterRolldown(staticReplaceList);
15
+ assert(include);
16
+ const filterRolldown = {
17
+ id: {
18
+ exclude: `**${skipNodeModules}**`,
19
+ },
20
+ code: {
21
+ include,
22
+ },
23
+ };
24
+ const filterFunction = (id, code) => {
25
+ if (id.includes(skipNodeModules))
26
+ return false;
27
+ if (!include.test(code))
28
+ return false;
29
+ return true;
30
+ };
13
31
  return [
14
32
  {
15
33
  name: 'vike:pluginStaticReplace',
@@ -20,13 +38,9 @@ function pluginStaticReplace(vikeConfig) {
20
38
  },
21
39
  },
22
40
  transform: {
23
- filter: {
24
- code: {
25
- include: filterRolldown.code.include,
26
- exclude: /node_modules/,
27
- },
28
- },
41
+ filter: filterRolldown,
29
42
  async handler(code, id, options) {
43
+ assert(filterFunction(id, code));
30
44
  const env = isViteServerSide_extraSafe(config, this.environment, options) ? 'server' : 'client';
31
45
  const result = await applyStaticReplace({
32
46
  code,
@@ -273,6 +273,7 @@ const configDefinitionsBuiltIn = {
273
273
  staticReplace: {
274
274
  env: { config: true },
275
275
  cumulative: true,
276
+ global: true,
276
277
  /* TODO
277
278
  vite: true,
278
279
  */
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.249-commit-ec50591";
1
+ export declare const PROJECT_VERSION: "0.4.249-commit-92f1383";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.249-commit-ec50591';
2
+ export const PROJECT_VERSION = '0.4.249-commit-92f1383';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.249-commit-ec50591",
3
+ "version": "0.4.249-commit-92f1383",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {