Skip to content

Commit a85b07a

Browse files
feat(enhanced): exclude shares by semver (#3744)
1 parent 731517b commit a85b07a

File tree

72 files changed

+6174
-1304
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+6174
-1304
lines changed

.cursorignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ webpack/benchmark/
2525
tools/
2626
.husky/
2727
.github/
28-
.vscode/
2928
.verdaccio/
3029

3130

.vscode/launch.json

Lines changed: 102 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,112 +2,176 @@
22
"version": "0.2.0",
33
"configurations": [
44
{
5-
"command": "npm run nx",
5+
"command": "pnpm run nx",
66
"name": "Run nx",
77
"request": "launch",
88
"type": "node-terminal"
99
},
1010
{
11-
"command": "npm run commit",
11+
"command": "pnpm run commit",
1212
"name": "Run commit",
1313
"request": "launch",
1414
"type": "node-terminal"
1515
},
1616
{
17-
"command": "npm run docs",
17+
"command": "pnpm run docs",
1818
"name": "Run docs",
1919
"request": "launch",
2020
"type": "node-terminal"
2121
},
2222
{
23-
"command": "npm run e2e:test",
24-
"name": "Run e2e:test",
25-
"request": "launch",
26-
"type": "node-terminal"
27-
},
28-
{
29-
"command": "npm run lint",
23+
"command": "pnpm run lint",
3024
"name": "Run lint",
3125
"request": "launch",
3226
"type": "node-terminal"
3327
},
3428
{
35-
"command": "npm run test",
36-
"name": "Run test",
37-
"request": "launch",
38-
"type": "node-terminal"
39-
},
40-
{
41-
"command": "npm run build",
29+
"command": "pnpm run build",
4230
"name": "Run build",
4331
"request": "launch",
4432
"type": "node-terminal"
4533
},
4634
{
47-
"command": "npm run lint-fix",
35+
"command": "pnpm run lint-fix",
4836
"name": "Run lint-fix",
4937
"request": "launch",
5038
"type": "node-terminal"
5139
},
5240
{
53-
"command": "npm run trigger-release",
41+
"command": "pnpm run trigger-release",
5442
"name": "Run trigger-release",
5543
"request": "launch",
5644
"type": "node-terminal"
5745
},
5846
{
59-
"command": "npm run serve:next",
47+
"command": "pnpm run serve:next",
6048
"name": "Run serve:next",
6149
"request": "launch",
6250
"type": "node-terminal"
6351
},
6452
{
65-
"command": "npm run serve:website",
53+
"command": "pnpm run serve:website",
6654
"name": "Run serve:website",
6755
"request": "launch",
6856
"type": "node-terminal"
6957
},
7058
{
71-
"command": "npm run build:website",
59+
"command": "pnpm run build:website",
7260
"name": "Run build:website",
7361
"request": "launch",
7462
"type": "node-terminal"
7563
},
7664
{
77-
"command": "npm run extract-i18n:website",
65+
"command": "pnpm run extract-i18n:website",
7866
"name": "Run extract-i18n:website",
7967
"request": "launch",
8068
"type": "node-terminal"
8169
},
8270
{
83-
"command": "npm run postinstall",
84-
"name": "Run postinstall",
85-
"request": "launch",
86-
"type": "node-terminal"
87-
},
88-
{
89-
"command": "npm run sync:types:webpack",
90-
"name": "Run sync:types:webpack",
91-
"request": "launch",
92-
"type": "node-terminal"
93-
},
94-
{
95-
"command": "npm run sync:pullMFTypes",
71+
"command": "pnpm run sync:pullMFTypes",
9672
"name": "Run sync:pullMFTypes",
9773
"request": "launch",
9874
"type": "node-terminal"
9975
},
10076
{
101-
"command": "npm run app:next:dev",
77+
"command": "pnpm run app:next:dev",
10278
"name": "Run app:next:dev",
10379
"request": "launch",
10480
"type": "node-terminal"
10581
},
10682
{
107-
"command": "npm run app:next:prod",
83+
"command": "pnpm run app:next:prod",
10884
"name": "Run app:next:prod",
10985
"request": "launch",
11086
"type": "node-terminal"
87+
},
88+
{
89+
"name": "Debug Enhanced Tests",
90+
"type": "node",
91+
"request": "launch",
92+
"preLaunchTask": "pnpm-build-enhanced",
93+
"runtimeExecutable": "/Users/bytedance/.nvm/versions/node/v18.20.8/bin/node",
94+
"runtimeArgs": [
95+
"${workspaceFolder}/node_modules/jest/bin/jest.js",
96+
"test/ConfigTestCases.basictest.js",
97+
"test/unit",
98+
"--runInBand",
99+
"--no-cache"
100+
],
101+
"cwd": "${workspaceFolder}/packages/enhanced",
102+
"console": "integratedTerminal",
103+
"internalConsoleOptions": "neverOpen",
104+
"env": {
105+
"NODE_OPTIONS": "--experimental-vm-modules"
106+
},
107+
"skipFiles": ["<node_internals>/**"],
108+
"outFiles": ["${workspaceFolder}/packages/enhanced/dist/**/*.js"],
109+
"sourceMaps": true
110+
},
111+
{
112+
"name": "Debug Current Test File",
113+
"type": "node",
114+
"request": "launch",
115+
"runtimeExecutable": "pnpm",
116+
"runtimeArgs": [
117+
"nx",
118+
"test",
119+
"${relativeFileDirname}",
120+
"--testFile=${fileBasename}",
121+
"--runInBand",
122+
"--no-cache"
123+
],
124+
"console": "integratedTerminal",
125+
"internalConsoleOptions": "neverOpen",
126+
"skipFiles": ["<node_internals>/**"],
127+
"env": {
128+
"NODE_ENV": "test"
129+
}
130+
},
131+
{
132+
"name": "Debug Package Tests",
133+
"type": "node",
134+
"request": "launch",
135+
"runtimeExecutable": "pnpm",
136+
"runtimeArgs": [
137+
"nx",
138+
"test",
139+
"${input:package}",
140+
"--runInBand",
141+
"--no-cache"
142+
],
143+
"console": "integratedTerminal",
144+
"internalConsoleOptions": "neverOpen",
145+
"skipFiles": ["<node_internals>/**"],
146+
"env": {
147+
"NODE_ENV": "test"
148+
}
149+
},
150+
{
151+
"name": "Debug All Tests",
152+
"type": "node",
153+
"request": "launch",
154+
"runtimeExecutable": "pnpm",
155+
"runtimeArgs": [
156+
"nx",
157+
"run-many",
158+
"--target=test",
159+
"--runInBand",
160+
"--no-cache"
161+
],
162+
"console": "integratedTerminal",
163+
"internalConsoleOptions": "neverOpen",
164+
"skipFiles": ["<node_internals>/**"],
165+
"env": {
166+
"NODE_ENV": "test"
167+
}
168+
}
169+
],
170+
"inputs": [
171+
{
172+
"id": "package",
173+
"type": "promptString",
174+
"description": "Enter the package name to test (e.g., enhanced, cli, runtime)"
111175
}
112176
]
113177
}

.vscode/tasks.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "pnpm-build-enhanced",
6+
"type": "shell",
7+
// Use nx to build only the 'enhanced' package dependencies if possible
8+
// Adjust 'enhanced' if the nx project name is different
9+
// --- Updated Command to include NVM ---
10+
// This assumes NVM is installed in the default location ($HOME/.nvm)
11+
// and uses the latest installed Node v18. Adjust if needed.
12+
"command": "source $HOME/.nvm/nvm.sh && nvm use 18 && pnpm nx build enhanced",
13+
// args are no longer needed as the full command is specified above
14+
// "args": ["nx", "build", "enhanced"],
15+
"problemMatcher": [],
16+
"options": {
17+
// Ensure the shell runs commands correctly
18+
"shell": {
19+
"executable": "/bin/zsh", // Or your preferred shell like /bin/bash
20+
"args": ["-l", "-c"] // Use login shell args to potentially source NVM automatically, then execute command
21+
}
22+
},
23+
"presentation": {
24+
"reveal": "silent", // Don't show the terminal panel unless there's an error
25+
"panel": "dedicated",
26+
"clear": true
27+
},
28+
"detail": "Sources NVM, uses Node v18, then builds the 'enhanced' package using nx."
29+
}
30+
]
31+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"commit": "cz",
2424
"docs": "typedoc",
2525
"f": "nx format:write",
26-
"enhanced:jest": "pnpm build && cd packages/enhanced && NODE_OPTIONS=--experimental-vm-modules npx jest test/ConfigTestCases.basictest.js test/unit",
26+
"enhanced:jest": "pnpm build && cd packages/enhanced && NODE_OPTIONS=--experimental-vm-modules npx jest test/ConfigTestCases.basictest.js test/unit test/compiler-unit",
2727
"lint": "nx run-many --target=lint",
2828
"test": "nx run-many --target=test",
2929
"build": "nx run-many --target=build --parallel=5 --projects=tag:type:pkg",

packages/chrome-devtools/project.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"executor": "nx:run-commands",
1010
"options": {
1111
"commands": ["npm run build:lib --prefix packages/chrome-devtools"]
12-
}
12+
},
13+
"dependsOn": ["^build"]
1314
},
1415
"build:chrome-plugins": {
1516
"executor": "nx:run-commands",

packages/enhanced/jest.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export default {
3636
testMatch: [
3737
'<rootDir>/test/*.basictest.js',
3838
'<rootDir>/test/unit/**/*.test.ts',
39+
'<rootDir>/test/compiler-unit/**/*.test.ts',
3940
],
4041

4142
testEnvironment: path.resolve(__dirname, './test/patch-node-env.js'),

packages/enhanced/src/declarations/plugins/sharing/ConsumeSharedModule.d.ts

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
import type { SemVerRange } from 'webpack/lib/util/semver';
2+
3+
export interface ConsumeSharedModuleExcludeOptions {
4+
request?: string | RegExp;
5+
version?: string;
6+
fallbackVersion?: string;
7+
}
8+
9+
export interface ConsumeSharedModuleIncludeOptions {
10+
request?: string | RegExp;
11+
version?: string;
12+
fallbackVersion?: string;
13+
}
14+
115
export type ConsumeOptions = {
216
/**
317
* fallback request
@@ -42,16 +56,6 @@ export type ConsumeOptions = {
4256
* include the fallback module in a sync way
4357
*/
4458
eager: boolean;
45-
/**
46-
* Filter object for consuming shared modules.
47-
*/
48-
filter?: {
49-
/**
50-
* RegExp to filter requests for prefix consumes.
51-
* Applied to the part of the request after the prefix.
52-
*/
53-
request?: RegExp;
54-
};
5559
/**
5660
* Share a specific layer of the module, if the module supports layers
5761
*/
@@ -60,4 +64,14 @@ export type ConsumeOptions = {
6064
* Issuer layer in which the module should be resolved
6165
*/
6266
issuerLayer?: string | null;
67+
/**
68+
* Filter object for consuming shared modules.
69+
* Modules matching the criteria in this object will be excluded.
70+
*/
71+
exclude?: ConsumeSharedModuleExcludeOptions;
72+
/**
73+
* Filter object for consuming shared modules.
74+
* Only modules matching the criteria in this object will be included.
75+
*/
76+
include?: ConsumeSharedModuleIncludeOptions;
6377
};

packages/enhanced/src/declarations/plugins/sharing/ConsumeSharedPlugin.d.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ export interface ConsumesObject {
3535
*/
3636
[k: string]: ConsumesConfig | ConsumesItem;
3737
}
38+
39+
export interface IncludeExcludeOptions {
40+
request?: string | RegExp;
41+
version?: string;
42+
fallbackVersion?: string;
43+
}
44+
3845
/**
3946
* Advanced configuration for modules that should be consumed from share scope.
4047
*/
@@ -83,7 +90,6 @@ export interface ConsumesConfig {
8390
* The actual request to use for importing the module. If not specified, the property name/key will be used.
8491
*/
8592
request?: string;
86-
filter?: {
87-
request?: RegExp;
88-
};
93+
exclude?: IncludeExcludeOptions;
94+
include?: IncludeExcludeOptions;
8995
}

packages/enhanced/src/declarations/plugins/sharing/ProvideSharedPlugin.d.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ export interface ProvidesObject {
3232
*/
3333
[k: string]: ProvidesConfig | ProvidesItem;
3434
}
35+
36+
export interface IncludeExcludeOptions {
37+
request?: string | RegExp;
38+
version?: string;
39+
fallbackVersion?: string;
40+
}
41+
3542
/**
3643
* Advanced configuration for modules that should be provided as shared modules to the share scope.
3744
*/
@@ -75,7 +82,9 @@ export interface ProvidesConfig {
7582
/**
7683
* Filter for the shared module.
7784
*/
78-
filter?: {
79-
request?: RegExp;
80-
};
85+
exclude?: IncludeExcludeOptions;
86+
/**
87+
* Filter for the shared module.
88+
*/
89+
include?: IncludeExcludeOptions;
8190
}

0 commit comments

Comments
 (0)