Skip to content

feat(misc): non conflicting init/add flow#22791

Merged
FrozenPandaz merged 2 commits into
nrwl:masterfrom
FrozenPandaz:init-lite
Apr 15, 2024
Merged

feat(misc): non conflicting init/add flow#22791
FrozenPandaz merged 2 commits into
nrwl:masterfrom
FrozenPandaz:init-lite

Conversation

@FrozenPandaz

@FrozenPandaz FrozenPandaz commented Apr 12, 2024

Copy link
Copy Markdown
Contributor

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 #

@vercel

vercel Bot commented Apr 12, 2024

Copy link
Copy Markdown

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

@AgentEnder AgentEnder left a comment

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
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' });

@github-actions

Copy link
Copy Markdown
Contributor

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.

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.

2 participants