Skip to content

feat(enhanced): exclude shares by semver #3744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 13 commits into
base: share-filter
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .cursorignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ webpack/benchmark/
tools/
.husky/
.github/
.vscode/
.verdaccio/


Expand Down
140 changes: 102 additions & 38 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,112 +2,176 @@
"version": "0.2.0",
"configurations": [
{
"command": "npm run nx",
"command": "pnpm run nx",
"name": "Run nx",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npm run commit",
"command": "pnpm run commit",
"name": "Run commit",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npm run docs",
"command": "pnpm run docs",
"name": "Run docs",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npm run e2e:test",
"name": "Run e2e:test",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npm run lint",
"command": "pnpm run lint",
"name": "Run lint",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npm run test",
"name": "Run test",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npm run build",
"command": "pnpm run build",
"name": "Run build",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npm run lint-fix",
"command": "pnpm run lint-fix",
"name": "Run lint-fix",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npm run trigger-release",
"command": "pnpm run trigger-release",
"name": "Run trigger-release",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npm run serve:next",
"command": "pnpm run serve:next",
"name": "Run serve:next",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npm run serve:website",
"command": "pnpm run serve:website",
"name": "Run serve:website",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npm run build:website",
"command": "pnpm run build:website",
"name": "Run build:website",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npm run extract-i18n:website",
"command": "pnpm run extract-i18n:website",
"name": "Run extract-i18n:website",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npm run postinstall",
"name": "Run postinstall",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npm run sync:types:webpack",
"name": "Run sync:types:webpack",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npm run sync:pullMFTypes",
"command": "pnpm run sync:pullMFTypes",
"name": "Run sync:pullMFTypes",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npm run app:next:dev",
"command": "pnpm run app:next:dev",
"name": "Run app:next:dev",
"request": "launch",
"type": "node-terminal"
},
{
"command": "npm run app:next:prod",
"command": "pnpm run app:next:prod",
"name": "Run app:next:prod",
"request": "launch",
"type": "node-terminal"
},
{
"name": "Debug Enhanced Tests",
"type": "node",
"request": "launch",
"preLaunchTask": "pnpm-build-enhanced",
"runtimeExecutable": "/Users/bytedance/.nvm/versions/node/v18.20.8/bin/node",
"runtimeArgs": [
"${workspaceFolder}/node_modules/jest/bin/jest.js",
"test/ConfigTestCases.basictest.js",
"test/unit",
"--runInBand",
"--no-cache"
],
"cwd": "${workspaceFolder}/packages/enhanced",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"env": {
"NODE_OPTIONS": "--experimental-vm-modules"
},
"skipFiles": ["<node_internals>/**"],
"outFiles": ["${workspaceFolder}/packages/enhanced/dist/**/*.js"],
"sourceMaps": true
},
{
"name": "Debug Current Test File",
"type": "node",
"request": "launch",
"runtimeExecutable": "pnpm",
"runtimeArgs": [
"nx",
"test",
"${relativeFileDirname}",
"--testFile=${fileBasename}",
"--runInBand",
"--no-cache"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"skipFiles": ["<node_internals>/**"],
"env": {
"NODE_ENV": "test"
}
},
{
"name": "Debug Package Tests",
"type": "node",
"request": "launch",
"runtimeExecutable": "pnpm",
"runtimeArgs": [
"nx",
"test",
"${input:package}",
"--runInBand",
"--no-cache"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"skipFiles": ["<node_internals>/**"],
"env": {
"NODE_ENV": "test"
}
},
{
"name": "Debug All Tests",
"type": "node",
"request": "launch",
"runtimeExecutable": "pnpm",
"runtimeArgs": [
"nx",
"run-many",
"--target=test",
"--runInBand",
"--no-cache"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"skipFiles": ["<node_internals>/**"],
"env": {
"NODE_ENV": "test"
}
}
],
"inputs": [
{
"id": "package",
"type": "promptString",
"description": "Enter the package name to test (e.g., enhanced, cli, runtime)"
}
]
}
31 changes: 31 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "pnpm-build-enhanced",
"type": "shell",
// Use nx to build only the 'enhanced' package dependencies if possible
// Adjust 'enhanced' if the nx project name is different
// --- Updated Command to include NVM ---
// This assumes NVM is installed in the default location ($HOME/.nvm)
// and uses the latest installed Node v18. Adjust if needed.
"command": "source $HOME/.nvm/nvm.sh && nvm use 18 && pnpm nx build enhanced",
// args are no longer needed as the full command is specified above
// "args": ["nx", "build", "enhanced"],
"problemMatcher": [],
"options": {
// Ensure the shell runs commands correctly
"shell": {
"executable": "/bin/zsh", // Or your preferred shell like /bin/bash
"args": ["-l", "-c"] // Use login shell args to potentially source NVM automatically, then execute command
}
},
"presentation": {
"reveal": "silent", // Don't show the terminal panel unless there's an error
"panel": "dedicated",
"clear": true
},
"detail": "Sources NVM, uses Node v18, then builds the 'enhanced' package using nx."
}
]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"commit": "cz",
"docs": "typedoc",
"f": "nx format:write",
"enhanced:jest": "pnpm build && cd packages/enhanced && NODE_OPTIONS=--experimental-vm-modules npx jest test/ConfigTestCases.basictest.js test/unit",
"enhanced:jest": "pnpm build && cd packages/enhanced && NODE_OPTIONS=--experimental-vm-modules npx jest test/ConfigTestCases.basictest.js test/unit test/compiler-unit",
"lint": "nx run-many --target=lint",
"test": "nx run-many --target=test",
"build": "nx run-many --target=build --parallel=5 --projects=tag:type:pkg",
Expand Down
3 changes: 2 additions & 1 deletion packages/chrome-devtools/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"executor": "nx:run-commands",
"options": {
"commands": ["npm run build:lib --prefix packages/chrome-devtools"]
}
},
"dependsOn": ["^build"]
},
"build:chrome-plugins": {
"executor": "nx:run-commands",
Expand Down
1 change: 1 addition & 0 deletions packages/enhanced/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default {
testMatch: [
'<rootDir>/test/*.basictest.js',
'<rootDir>/test/unit/**/*.test.ts',
'<rootDir>/test/compiler-unit/**/*.test.ts',
],

testEnvironment: path.resolve(__dirname, './test/patch-node-env.js'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,21 @@ export type ConsumeOptions = {
/**
* Filter object for consuming shared modules.
*/
filter?: {
exclude?: {
/**
* RegExp to filter requests for prefix consumes.
* Applied to the part of the request after the prefix.
*/
request?: RegExp;
/**
* Version range to filter against. Modules matching this range will be excluded.
*/
version?: string;
/**
* Optional specific version to check against the filter.version range.
* If provided, this is used instead of reading from package.json.
*/
fallbackVersion?: string;
};
/**
* Share a specific layer of the module, if the module supports layers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ export interface ConsumesConfig {
* The actual request to use for importing the module. If not specified, the property name/key will be used.
*/
request?: string;
filter?: {
exclude?: {
request?: RegExp;
version?: string;
fallbackVersion?: string;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ export interface ProvidesConfig {
/**
* Filter for the shared module.
*/
filter?: {
exclude?: {
request?: RegExp;
version?: string;
fallbackVersion?: string;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ export interface SharedConfig {
/**
* Filter for the shared module.
*/
filter?: {
exclude?: {
request?: RegExp;
version?: string;
fallbackVersion?: string;
};
}
1 change: 1 addition & 0 deletions packages/enhanced/src/lib/sharing/ConsumeSharedModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const makeSerializable = require(
* @property {boolean} eager include the fallback module in a sync way
* @property {string | null=} layer Share a specific layer of the module, if the module supports layers
* @property {string | null=} issuerLayer Issuer layer in which the module should be resolved
* @property {{ version?: string; fallbackVersion?: string }} exclude Options for excluding certain versions
*/

const TYPES = new Set(['consume-shared']);
Expand Down
Loading