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(misc): non conflicting init/add flow #22791

Merged
merged 2 commits into from Apr 15, 2024

Conversation

FrozenPandaz
Copy link
Collaborator

@FrozenPandaz FrozenPandaz commented Apr 12, 2024

Current Behavior

When initializing a plugin, the same target name is always chosen. Sometimes, this may conflict with existing targets. For example, if you already have a build npm script, as a build target, then the build target coming in from the vite plugin overrides it. This may cause unexpected behavior resulting from adding the plugin. Already in the current version, we combat this by not including npm scripts as targets. However, for targets like build, the npm script is likely what people are already considering their defacto build script.

Expected Behavior

Plugins are initialized with a set of possible options. The option which does not conflict with the current graph is chosen. If none of the provided options does not conflict, an error is thrown. The plugins prefer the shorter more general target name such as build however, will shift to target names such as vite:build for the vite plugin.

Because plugins now ensure that they don't conflict with the existing graph, we can now add npm scripts by default. As such, the nx init flow has also been updated to add those npm scripts. This results in an nx init flow which is more incremental. You can now start at package-based with no plugins and add plugins afterwards with no worry of plugins altering the existing project graph. In addition, plugins are not selected by default in the init flow as they are easier to add later.

https://nx-dev-git-fork-frozenpandaz-init-lite-nrwl.vercel.app/recipes/adopting-nx/adding-to-monorepo

Related Issue(s)

Fixes #

Copy link

vercel bot commented Apr 12, 2024

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

Name Status Preview Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview Apr 15, 2024 7:56pm

@FrozenPandaz FrozenPandaz force-pushed the init-lite branch 6 times, most recently from a41e685 to bb8c8a1 Compare April 12, 2024 14:07
@FrozenPandaz FrozenPandaz force-pushed the init-lite branch 2 times, most recently from 714cbaa to 1bcacf3 Compare April 12, 2024 19:00
@FrozenPandaz FrozenPandaz force-pushed the init-lite branch 2 times, most recently from 3a3e95c to f5d937b Compare April 12, 2024 20:30
Copy link
Member

@AgentEnder AgentEnder left a comment

Choose a reason for hiding this comment

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

Looks good, one minor nitpick that may be worth changing


runInstall(repoRoot, pmc);

output.log({ title: '🔨 Configuring plugins' });
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
output.log({ title: '🔨 Configuring plugins' });
if (plugins.length)
output.log({ title: '🔨 Configuring plugins' });

@FrozenPandaz FrozenPandaz merged commit bf206e5 into nrwl:master Apr 15, 2024
6 checks passed
@FrozenPandaz FrozenPandaz deleted the init-lite branch April 15, 2024 20:45
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.

None yet

2 participants