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

fix(core): add 'dependsOn' property in when inferring build targets via plugins #20614

Merged
merged 1 commit into from
Dec 6, 2023
Merged
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
6 changes: 6 additions & 0 deletions packages/nuxt/src/plugins/__snapshots__/plugin.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ exports[`@nx/nuxt/plugin not root project should create nodes 1`] = `
"build-something": {
"cache": true,
"command": "nuxi build",
"dependsOn": [
"^build-something",
],
"inputs": [
"default",
"^production",
Expand Down Expand Up @@ -66,6 +69,9 @@ exports[`@nx/nuxt/plugin root project should create nodes 1`] = `
"build": {
"cache": true,
"command": "nuxi build",
"dependsOn": [
"^build",
],
"inputs": [
"default",
"^production",
Expand Down
3 changes: 3 additions & 0 deletions packages/nuxt/src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ async function buildNuxtTargets(
const targets: Record<string, TargetConfiguration> = {};

targets[options.buildTargetName] = buildTarget(
options.buildTargetName,
namedInputs,
buildOutputs,
projectRoot
Expand All @@ -118,6 +119,7 @@ async function buildNuxtTargets(
}

function buildTarget(
buildTargetName: string,
namedInputs: {
[inputName: string]: any[];
},
Expand All @@ -128,6 +130,7 @@ function buildTarget(
command: `nuxi build`,
options: { cwd: projectRoot },
cache: true,
dependsOn: [`^${buildTargetName}`],
inputs: [
...('production' in namedInputs
? ['default', '^production']
Expand Down
6 changes: 6 additions & 0 deletions packages/vite/src/plugins/__snapshots__/plugin.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ exports[`@nx/vite/plugin not root project should create nodes 1`] = `
"build-something": {
"cache": true,
"command": "vite build",
"dependsOn": [
"^build-something",
],
"inputs": [
"production",
"^production",
Expand Down Expand Up @@ -77,6 +80,9 @@ exports[`@nx/vite/plugin root project should create nodes 1`] = `
"build": {
"cache": true,
"command": "vite build",
"dependsOn": [
"^build",
],
"inputs": [
"production",
"^production",
Expand Down
3 changes: 3 additions & 0 deletions packages/vite/src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ async function buildViteTargets(
const targets: Record<string, TargetConfiguration> = {};

targets[options.buildTargetName] = await buildTarget(
options.buildTargetName,
namedInputs,
buildOutputs,
projectRoot
Expand All @@ -131,6 +132,7 @@ async function buildViteTargets(
}

async function buildTarget(
buildTargetName: string,
namedInputs: {
[inputName: string]: any[];
},
Expand All @@ -141,6 +143,7 @@ async function buildTarget(
command: `vite build`,
options: { cwd: joinPathFragments(projectRoot) },
cache: true,
dependsOn: [`^${buildTargetName}`],
inputs: [
...('production' in namedInputs
? ['production', '^production']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ exports[`@nx/webpack/plugin should create nodes 1`] = `
"build-something": {
"cache": true,
"command": "webpack -c webpack.config.js --node-env=production",
"dependsOn": [
"^build-something",
],
"inputs": [
"default",
"^production",
Expand Down
1 change: 1 addition & 0 deletions packages/webpack/src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ async function createWebpackTargets(
command: `webpack -c ${configBasename} --node-env=production`,
options: { cwd: projectRoot },
cache: true,
dependsOn: [`^${options.buildTargetName}`],
inputs:
'production' in namedInputs
? [
Expand Down