-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): React workspaces that use pnpm & the new TS solution shoul…
…d be declared correctly so that it can be referenced.
- Loading branch information
1 parent
28c53f9
commit 664eefc
Showing
21 changed files
with
246 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
const { load } = require('@zkochan/js-yaml'); | ||
import { | ||
cleanupProject, | ||
runCLI, | ||
newProject, | ||
ensureCypressInstallation, | ||
uniq, | ||
readJson, | ||
} from '@nx/e2e/utils'; | ||
|
||
describe('React typescript project references PM = npm', () => { | ||
beforeEach(() => { | ||
cleanupProject(); | ||
newProject({ | ||
packages: ['@nx/react'], | ||
packageManager: 'npm', | ||
workspaces: true, | ||
}); | ||
ensureCypressInstallation(); | ||
}); | ||
|
||
afterEach(() => cleanupProject()); | ||
it('None buildable libs using should be excluded from js/ts plugin', async () => { | ||
const appName = uniq('app'); | ||
const libName = uniq('lib'); | ||
|
||
runCLI( | ||
`generate @nx/react:app apps/${appName} --name=${appName} --useTsSolution=true --bundler=vite --no-interactive --skipFormat --linter=eslint --unitTestRunner=vitest` | ||
); | ||
runCLI( | ||
`generate @nx/react:lib ${libName} --bundler=none --no-interactive --unit-test-runner=vitest --skipFormat --linter=eslint` | ||
); | ||
|
||
const nxJson = readJson('nx.json'); | ||
|
||
const jsTypescriptPlugin = nxJson.plugins.find( | ||
(plugin) => plugin.plugin === '@nx/js/typescript' | ||
); | ||
expect(jsTypescriptPlugin).toBeDefined(); | ||
|
||
expect(jsTypescriptPlugin.exclude.includes(`${libName}/*`)).toBeTruthy(); | ||
}, 250_000); | ||
|
||
it('Apps/libs using should be added to workspaces', async () => { | ||
const appName = uniq('app'); | ||
const libName = uniq('lib'); | ||
|
||
runCLI( | ||
`generate @nx/react:app apps/${appName} --name=${appName} --useTsSolution=true --bundler=vite --no-interactive --skipFormat --linter=eslint --unitTestRunner=vitest` | ||
); | ||
runCLI( | ||
`generate @nx/react:lib ${libName} --bundler=vite --no-interactive --unit-test-runner=vitest --skipFormat --linter=eslint` | ||
); | ||
|
||
const packageJson = readJson('package.json'); | ||
expect(packageJson.workspaces).toContain(`apps/${appName}`); | ||
expect(packageJson.workspaces).toContain(`${libName}/*`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
const { load } = require('@zkochan/js-yaml'); | ||
import { | ||
cleanupProject, | ||
runCLI, | ||
newProject, | ||
ensureCypressInstallation, | ||
uniq, | ||
readFile, | ||
readJson, | ||
} from '@nx/e2e/utils'; | ||
|
||
describe('React typescript project references PM = pnpm', () => { | ||
beforeAll(() => { | ||
newProject({ | ||
packages: ['@nx/react'], | ||
packageManager: 'pnpm', | ||
workspaces: true, | ||
}); | ||
|
||
ensureCypressInstallation(); | ||
}); | ||
|
||
afterAll(() => cleanupProject()); | ||
|
||
it('None buildable libs using should be excluded from js/ts plugin', async () => { | ||
const appName = uniq('app'); | ||
const libName = uniq('lib'); | ||
|
||
runCLI( | ||
`generate @nx/react:app apps/${appName} --name=${appName} --useTsSolution=true --bundler=vite --no-interactive --skipFormat --linter=eslint --unitTestRunner=vitest` | ||
); | ||
runCLI( | ||
`generate @nx/react:lib ${libName} --bundler=none --no-interactive --unit-test-runner=vitest --skipFormat --linter=eslint` | ||
); | ||
|
||
const nxJson = readJson('nx.json'); | ||
|
||
const jsTypescriptPlugin = nxJson.plugins.find( | ||
(plugin) => plugin.plugin === '@nx/js/typescript' | ||
); | ||
expect(jsTypescriptPlugin).toBeDefined(); | ||
|
||
expect(jsTypescriptPlugin.exclude.includes(`${libName}/*`)).toBeTruthy(); | ||
}, 250_000); | ||
|
||
it('PNPM Apps/libs using should be added to workspaces', async () => { | ||
const appName = uniq('app'); | ||
const libName = uniq('lib'); | ||
|
||
runCLI( | ||
`generate @nx/react:app apps/${appName} --name=${appName} --useTsSolution=true --bundler=vite --no-interactive --skipFormat --linter=eslint --unitTestRunner=vitest` | ||
); | ||
runCLI( | ||
`generate @nx/react:lib ${libName} --bundler=vite --no-interactive --unit-test-runner=vitest --skipFormat --linter=eslint` | ||
); | ||
|
||
const pnpmWorkspaceContent = readFile('pnpm-workspace.yaml'); | ||
const pnmpWorkspaceYaml = load(pnpmWorkspaceContent); | ||
expect(pnmpWorkspaceYaml.packages).toContain(`apps/${appName}`); | ||
expect(pnmpWorkspaceYaml.packages).toContain(`${libName}/*`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.