Skip to content

Commit

Permalink
fix(core): add 'dependsOn' property in when inferring build targets v…
Browse files Browse the repository at this point in the history
…ia plugins (nrwl#20614)
  • Loading branch information
jaysoo authored Dec 6, 2023
1 parent 0618ba4 commit 3493c78
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 0 deletions.
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

0 comments on commit 3493c78

Please sign in to comment.