Skip to content
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

feat(core): load native files from tmp location instead of node_modules #22648

Merged
merged 4 commits into from
Apr 17, 2024

Conversation

MaxKless
Copy link
Collaborator

@MaxKless MaxKless commented Apr 3, 2024

Current Behavior

Currently native code is loaded straight from the package location in node_modules (for example a nx.darwin-arm64.node file).
This is causing issues - especially on windows - when trying to delete node_modules or reinstalling packages while the file is still held in memory. This often surfaces in Nx Console where the daemon is started in the background.

Expected Behavior

Users should be able to delete node_modules at will without having to worry about whether the daemon is still running & locking files in the background.

Fixes nrwl/nx-console#1863

Copy link

vercel bot commented Apr 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Apr 17, 2024 8:17am

.eslintrc.json Outdated Show resolved Hide resolved
packages/nx/src/daemon/client/client.ts Outdated Show resolved Hide resolved
packages/nx/src/native/import.js Outdated Show resolved Hide resolved
packages/nx/src/native/native-file-cache-location.ts Outdated Show resolved Hide resolved
packages/nx/src/native/import.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@FrozenPandaz FrozenPandaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The js file that napi produces is set in packages/nx/project.json. If you update that, then you can keep the index file the correct import path.

No more lint rule
No more merge conflicts
No more weird imports

@MaxKless MaxKless force-pushed the native-execution-outside-nodemodules branch from a52ad76 to 480c972 Compare April 12, 2024 06:47
@MaxKless MaxKless force-pushed the native-execution-outside-nodemodules branch from 6991b52 to b9d8396 Compare April 15, 2024 09:39
@MaxKless MaxKless requested a review from a team as a code owner April 15, 2024 11:41
@MaxKless MaxKless force-pushed the native-execution-outside-nodemodules branch 2 times, most recently from 280837b to dedb502 Compare April 16, 2024 08:36
@MaxKless MaxKless force-pushed the native-execution-outside-nodemodules branch from dedb502 to 97efb73 Compare April 16, 2024 08:43
@MaxKless MaxKless force-pushed the native-execution-outside-nodemodules branch from 97efb73 to 1b60ef5 Compare April 16, 2024 09:02
packages/nx/src/daemon/cache.ts Outdated Show resolved Hide resolved
packages/nx/src/daemon/client/client.ts Outdated Show resolved Hide resolved
packages/nx/src/native/index.js Outdated Show resolved Hide resolved
packages/nx/src/native/index.js Show resolved Hide resolved
packages/nx/src/project-graph/project-graph-error.ts Outdated Show resolved Hide resolved
Comment on lines +7 to +39
const nxPackages = new Set([
'@nx/nx-android-arm64',
'@nx/nx-android-arm-eabi',
'@nx/nx-win32-x64-msvc',
'@nx/nx-win32-ia32-msvc',
'@nx/nx-win32-arm64-msvc',
'@nx/nx-darwin-universal',
'@nx/nx-darwin-x64',
'@nx/nx-darwin-arm64',
'@nx/nx-freebsd-x64',
'@nx/nx-linux-x64-musl',
'@nx/nx-linux-x64-gnu',
'@nx/nx-linux-arm64-musl',
'@nx/nx-linux-arm64-gnu',
'@nx/nx-linux-arm-gnueabihf',
]);

let nativeBinding = null
let localFileExisted = false
let loadError = null
const localNodeFiles = [
'nx.android-arm64.node',
'nx.android-arm-eabi.node',
'nx.win32-x64-msvc.node',
'nx.win32-ia32-msvc.node',
'nx.win32-arm64-msvc.node',
'nx.darwin-universal.node',
'nx.darwin-x64.node',
'nx.darwin-arm64.node',
'nx.freebsd-x64.node',
'nx.linux-x64-musl.node',
'nx.linux-x64-gnu.node',
'nx.linux-arm64-musl.node',
'nx.linux-arm64-gnu.node',
'nx.linux-arm-gnueabihf.node',
];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Followup: Can we make these lists by reading package.json?

@FrozenPandaz FrozenPandaz merged commit da1808d into master Apr 17, 2024
6 checks passed
@FrozenPandaz FrozenPandaz deleted the native-execution-outside-nodemodules branch April 17, 2024 15:14
FrozenPandaz pushed a commit that referenced this pull request Apr 18, 2024
AgentEnder pushed a commit to AgentEnder/nx that referenced this pull request Apr 23, 2024
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plugin interferes with the deletion of the node_modules
2 participants