Skip to content

Commit

Permalink
Merge branch 'master' into fix/use-standard-args-parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz committed Oct 26, 2023
2 parents aa843f7 + 7942ea3 commit ea6674f
Show file tree
Hide file tree
Showing 13 changed files with 183 additions and 24 deletions.
2 changes: 1 addition & 1 deletion docs/generated/cli/create-nx-workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Package manager to use

Type: `string`

Customizes the initial content of your workspace. Default presets include: ["apps", "empty", "core", "npm", "ts", "web-components", "angular-monorepo", "angular-standalone", "react-monorepo", "react-standalone", "next", "nextjs-standalone", "react-native", "expo", "nest", "express", "react", "angular", "node-standalone", "node-monorepo", "ts-standalone"]. To build your own see https://nx.dev/extending-nx/recipes/create-preset
Customizes the initial content of your workspace. Default presets include: ["apps", "empty", "core", "npm", "ts", "web-components", "angular-monorepo", "angular-standalone", "react-monorepo", "react-standalone", "vue-monorepo", "vue-standalone", "next", "nextjs-standalone", "react-native", "expo", "nest", "express", "react", "angular", "node-standalone", "node-monorepo", "ts-standalone"]. To build your own see https://nx.dev/extending-nx/recipes/create-preset

### routing

Expand Down
6 changes: 6 additions & 0 deletions docs/generated/packages/js/generators/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
"default": false,
"x-priority": "internal"
},
"skipPackageJson": {
"description": "Do not add dependencies to `package.json`.",
"type": "boolean",
"default": false,
"x-priority": "internal"
},
"skipTsConfig": {
"type": "boolean",
"description": "Do not update tsconfig.json for development experience.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Package manager to use

Type: `string`

Customizes the initial content of your workspace. Default presets include: ["apps", "empty", "core", "npm", "ts", "web-components", "angular-monorepo", "angular-standalone", "react-monorepo", "react-standalone", "next", "nextjs-standalone", "react-native", "expo", "nest", "express", "react", "angular", "node-standalone", "node-monorepo", "ts-standalone"]. To build your own see https://nx.dev/extending-nx/recipes/create-preset
Customizes the initial content of your workspace. Default presets include: ["apps", "empty", "core", "npm", "ts", "web-components", "angular-monorepo", "angular-standalone", "react-monorepo", "react-standalone", "vue-monorepo", "vue-standalone", "next", "nextjs-standalone", "react-native", "expo", "nest", "express", "react", "angular", "node-standalone", "node-monorepo", "ts-standalone"]. To build your own see https://nx.dev/extending-nx/recipes/create-preset

### routing

Expand Down
1 change: 0 additions & 1 deletion nx-dev/nx-dev/redirect-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@ const nxCloudUrls = {
'/nx-cloud/recipes/set-up/monorepo-ci-bitbucket-pipelines',
'/recipes/ci/ci-deployment': '/nx-cloud/recipes/other/ci-deployment',
'/nx-cloud/intro/what-is-nx-cloud': '/nx-cloud/intro/ci-with-nx',
'/nx-cloud/intro/nx-cloud-workflows': '/nx-cloud/intro/nx-cloud-workflows',
'/nx-cloud/set-up': '/nx-cloud/recipes/set-up',
'/nx-cloud/set-up/record-commands': '/nx-cloud/recipes/other/record-commands',
'/nx-cloud/set-up/github':
Expand Down
4 changes: 0 additions & 4 deletions packages/create-nx-workspace/bin/create-nx-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@ export const commandsObject: yargs.Argv<Arguments> = yargs
describe: chalk.dim`Customizes the initial content of your workspace. Default presets include: [${Object.values(
Preset
)
// TODO(v17): Remove this option when @nx/vue is released.
.filter(
(p) => p !== Preset.VueStandalone && p !== Preset.VueMonorepo
)
.map((p) => `"${p}"`)
.join(
', '
Expand Down
1 change: 1 addition & 0 deletions packages/js/babel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ module.exports = function (api: any, options: NxWebBabelPresetOptions = {}) {
require.resolve('@babel/plugin-proposal-decorators'),
options.decorators ?? { legacy: true },
],
[require.resolve('@babel/plugin-transform-class-properties'), { loose }],
].filter(Boolean),
overrides: [
// Convert `const enum` to `enum`. The former cannot be supported by babel
Expand Down
1 change: 1 addition & 0 deletions packages/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@babel/core": "^7.22.9",
"@babel/plugin-proposal-decorators": "^7.22.7",
"@babel/plugin-transform-runtime": "^7.22.9",
"@babel/plugin-transform-class-properties": "^7.22.5",
"@babel/preset-env": "^7.22.9",
"@babel/preset-typescript": "^7.22.5",
"@babel/runtime": "^7.22.6",
Expand Down
28 changes: 28 additions & 0 deletions packages/js/src/generators/library/library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1359,4 +1359,32 @@ describe('lib', () => {
expect(tree.exists('web/my-lib/src/lib/my-lib.ts')).toBeTruthy();
});
});

describe('--testEnvironment', () => {
it('should generate a vite config with testEnvironment set to node', async () => {
await libraryGenerator(tree, {
...defaultOptions,
name: 'my-node-lib',
unitTestRunner: 'vitest',
testEnvironment: 'node',
});

const content = tree.read('my-node-lib/vite.config.ts', 'utf-8');

expect(content).toContain(`environment: 'node'`);
});

it('should generate a vite config with testEnvironment set to jsdom by default', async () => {
await libraryGenerator(tree, {
...defaultOptions,
name: 'my-jsdom-lib',
unitTestRunner: 'vitest',
testEnvironment: undefined,
});

const content = tree.read('my-jsdom-lib/vite.config.ts', 'utf-8');

expect(content).toContain(`environment: 'jsdom'`);
});
});
});
7 changes: 5 additions & 2 deletions packages/js/src/generators/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export async function libraryGeneratorInternal(

addProject(tree, options);

tasks.push(addProjectDependencies(tree, options));
if (!options.skipPackageJson) {
tasks.push(addProjectDependencies(tree, options));
}

if (options.publishable) {
tasks.push(await setupVerdaccio(tree, { ...options, skipFormat: true }));
Expand All @@ -99,6 +101,7 @@ export async function libraryGeneratorInternal(
project: options.name,
includeLib: true,
includeVitest: options.unitTestRunner === 'vitest',
testEnvironment: options.testEnvironment,
},
false
);
Expand Down Expand Up @@ -136,6 +139,7 @@ export async function libraryGeneratorInternal(
project: options.name,
includeLib: false,
includeVitest: true,
testEnvironment: options.testEnvironment,
},
true
);
Expand Down Expand Up @@ -706,7 +710,6 @@ function addProjectDependencies(
}

// Vite is being installed in the next step if bundler is vite

// noop
return () => {};
}
Expand Down
6 changes: 6 additions & 0 deletions packages/js/src/generators/library/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
"default": false,
"x-priority": "internal"
},
"skipPackageJson": {
"description": "Do not add dependencies to `package.json`.",
"type": "boolean",
"default": false,
"x-priority": "internal"
},
"skipTsConfig": {
"type": "boolean",
"description": "Do not update tsconfig.json for development experience.",
Expand Down
1 change: 1 addition & 0 deletions packages/js/src/utils/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface LibraryGeneratorSchema {
skipFormat?: boolean;
tags?: string;
skipTsConfig?: boolean;
skipPackageJson?: boolean;
includeBabelRc?: boolean;
unitTestRunner?: 'jest' | 'vitest' | 'none';
linter?: Linter;
Expand Down

0 comments on commit ea6674f

Please sign in to comment.