-
Notifications
You must be signed in to change notification settings - Fork 407
[Package] Exclude unused dependencies when building package.json files
#3232
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
Open
mho22
wants to merge
6
commits into
trunk
Choose a base branch
from
exclude-unused-dependencies-when-building-package-json-files
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dba3671
Add tests to highlight the presence of the unused dependency
mho22 2e7b092
Rearranged test files in test directories in php-wasm
mho22 f01b374
Rearranged test files in test directories in playground packages
mho22 47d94f6
Improved executor to only list dependencies needed from source files
mho22 e629587
Implement dependency test in test-built-npm-packages
mho22 9c08895
Renamed Xdebug bridge test directory and added 'tests' directory chec…
mho22 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...-wasm/node-polyfills/src/lib/blob.spec.ts → ...wasm/node-polyfills/src/test/blob.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import './blob'; | ||
| import '../lib/blob'; | ||
|
|
||
| describe('File class', () => { | ||
| it('Should exist', () => { | ||
|
|
||
2 changes: 1 addition & 1 deletion
2
...de-polyfills/src/lib/custom-event.spec.ts → ...e-polyfills/src/test/custom-event.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...progress/src/lib/progress-tracker.spec.ts → ...rogress/src/test/progress-tracker.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,117 +1 @@ | ||
| /** | ||
| * Scopes are unique strings, like `my-site`, used to uniquely brand | ||
| * the outgoing HTTP traffic from each browser tab. This helps the | ||
| * main thread distinguish between the relevant and irrelevant | ||
| * messages received from the Service Worker. | ||
| * | ||
| * Scopes are included in the `PHPRequestHandler.absoluteUrl` as follows: | ||
| * | ||
| * An **unscoped** URL: http://localhost:8778/wp-login.php | ||
| * A **scoped** URL: http://localhost:8778/scope:my-site/wp-login.php | ||
| * | ||
| * For more information, see the README section on scopes. | ||
| */ | ||
|
|
||
| /** | ||
| * Checks if the given URL contains scope information. | ||
| * | ||
| * @example | ||
| * ```js | ||
| * isURLScoped(new URL('http://localhost/scope:my-site/index.php')); | ||
| * // true | ||
| * | ||
| * isURLScoped(new URL('http://localhost/index.php')); | ||
| * // false | ||
| * ``` | ||
| * | ||
| * @param url The URL to check. | ||
| * @returns `true` if the URL contains scope information, `false` otherwise. | ||
| */ | ||
| export function isURLScoped(url: URL): boolean { | ||
| return url.pathname.startsWith(`/scope:`); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the scope stored in the given URL. | ||
| * | ||
| * @example | ||
| * ```js | ||
| * getScopeFromURL(new URL('http://localhost/scope:my-site/index.php')); | ||
| * // '96253' | ||
| * | ||
| * getScopeFromURL(new URL('http://localhost/index.php')); | ||
| * // null | ||
| * ``` | ||
| * | ||
| * @param url The URL. | ||
| * @returns The scope if the URL contains a scope, `null` otherwise. | ||
| */ | ||
| export function getURLScope(url: URL): string | null { | ||
| if (isURLScoped(url)) { | ||
| return url.pathname.split('/')[1].split(':')[1]; | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| /** | ||
| * Returns a new URL with the requested scope information. | ||
| * | ||
| * @example | ||
| * ```js | ||
| * setURLScope(new URL('http://localhost/index.php'), 'my-site'); | ||
| * // URL('http://localhost/scope:my-site/index.php') | ||
| * | ||
| * setURLScope(new URL('http://localhost/scope:my-site/index.php'), 'my-site'); | ||
| * // URL('http://localhost/scope:my-site/index.php') | ||
| * | ||
| * setURLScope(new URL('http://localhost/index.php'), null); | ||
| * // URL('http://localhost/index.php') | ||
| * ``` | ||
| * | ||
| * @param url The URL to scope. | ||
| * @param scope The scope value. | ||
| * @returns A new URL with the scope information in it. | ||
| */ | ||
| export function setURLScope(url: URL | string, scope: string | null): URL { | ||
| let newUrl = new URL(url); | ||
|
|
||
| if (isURLScoped(newUrl)) { | ||
| if (scope) { | ||
| const parts = newUrl.pathname.split('/'); | ||
| parts[1] = `scope:${scope}`; | ||
| newUrl.pathname = parts.join('/'); | ||
| } else { | ||
| newUrl = removeURLScope(newUrl); | ||
| } | ||
| } else if (scope) { | ||
| const suffix = newUrl.pathname === '/' ? '' : newUrl.pathname; | ||
| newUrl.pathname = `/scope:${scope}${suffix}`; | ||
| } | ||
|
|
||
| return newUrl; | ||
| } | ||
|
|
||
| /** | ||
| * Returns a new URL without any scope information. | ||
| * | ||
| * @example | ||
| * ```js | ||
| * removeURLScope(new URL('http://localhost/scope:my-site/index.php')); | ||
| * // URL('http://localhost/index.php') | ||
| * | ||
| * removeURLScope(new URL('http://localhost/index.php')); | ||
| * // URL('http://localhost/index.php') | ||
| * ``` | ||
| * | ||
| * @param url The URL to remove scope information from. | ||
| * @returns A new URL without the scope information. | ||
| */ | ||
| export function removeURLScope(url: URL): URL { | ||
| if (!isURLScoped(url)) { | ||
| return url; | ||
| } | ||
| const newUrl = new URL(url); | ||
| const parts = newUrl.pathname.split('/'); | ||
| newUrl.pathname = '/' + parts.slice(2).join('/'); | ||
| return newUrl; | ||
| } | ||
| export * from './lib/scope'; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These imports reach into Nx internal source paths (
nx/src/...), which are not part of the public API surface and can break on Nx upgrades or even patch releases. If possible, prefer a public@nx/devkitAPI (or encapsulate this behind a small compatibility layer with a well-defined fallback) so the executor remains stable across Nx versions.