Skip to content

Commit

Permalink
feat(js): new workspace uses scoped named in root package.json (#28271)
Browse files Browse the repository at this point in the history
This PR changes the root `package.json` to use a scoped name when using
`create-nx-workspace`. This was already done in most presets, but we
missed the old "package-based" setup.

e.g. These

```
create-nx-workspace acme --preset=ts
create-nx-workspace acme --preset=npm
```

Should all result in `@acme/source` being used in root `package.json`,
not `acme`. The scope will be used when generating projects if the user
doesn't pass `--importPath`.
  • Loading branch information
jaysoo authored Oct 3, 2024
1 parent 5be5ad8 commit f22c63d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions e2e/workspace-create/src/create-nx-workspace-npm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('create-nx-workspace --preset=npm', () => {
checkFilesExist('tsconfig.base.json');
const tsconfig = readJson(`tsconfig.base.json`);
expect(tsconfig.compilerOptions.paths).toEqual({
[libName]: [`packages/${libName}/src/index.ts`],
[`@${wsName}/${libName}`]: [`packages/${libName}/src/index.ts`],
});
}, 1_000_000);

Expand All @@ -83,7 +83,7 @@ describe('create-nx-workspace --preset=npm', () => {
checkFilesExist('tsconfig.base.json');
const tsconfig = readJson(`tsconfig.base.json`);
expect(tsconfig.compilerOptions.paths).toEqual({
[libName]: [`packages/${libName}/src/index.ts`],
[`@${wsName}/${libName}`]: [`packages/${libName}/src/index.ts`],
});
});

Expand Down Expand Up @@ -120,7 +120,7 @@ describe('create-nx-workspace --preset=npm', () => {
checkFilesExist('tsconfig.base.json');
const tsconfig = readJson(`tsconfig.base.json`);
expect(tsconfig.compilerOptions.paths).toEqual({
[libName]: [`packages/${libName}/src/index.ts`],
[`@${wsName}/${libName}`]: [`packages/${libName}/src/index.ts`],
});
});

Expand All @@ -146,8 +146,8 @@ describe('create-nx-workspace --preset=npm', () => {
checkFilesExist('tsconfig.base.json');
const tsconfig = readJson(`tsconfig.base.json`);
expect(tsconfig.compilerOptions.paths).toEqual({
[libName]: [`packages/${libName}/src/index.ts`],
[`${libName}/server`]: [`packages/${libName}/src/server.ts`],
[`@${wsName}/${libName}`]: [`packages/${libName}/src/index.ts`],
[`@${wsName}/${libName}/server`]: [`packages/${libName}/src/server.ts`],
});
});

Expand Down Expand Up @@ -177,7 +177,7 @@ describe('create-nx-workspace --preset=npm', () => {
checkFilesExist('tsconfig.base.json');
const tsconfig = readJson(`tsconfig.base.json`);
expect(tsconfig.compilerOptions.paths).toEqual({
[libName]: [`packages/${libName}/src/index.ts`],
[`@${wsName}/${libName}`]: [`packages/${libName}/src/index.ts`],
});
});

Expand All @@ -203,7 +203,7 @@ describe('create-nx-workspace --preset=npm', () => {
checkFilesExist('tsconfig.base.json');
const tsconfig = readJson(`tsconfig.base.json`);
expect(tsconfig.compilerOptions.paths).toEqual({
[libName]: [`packages/${libName}/src/index.ts`],
[`@${wsName}/${libName}`]: [`packages/${libName}/src/index.ts`],
});
});

Expand All @@ -229,7 +229,7 @@ describe('create-nx-workspace --preset=npm', () => {
checkFilesExist('tsconfig.base.json');
const tsconfig = readJson(`tsconfig.base.json`);
expect(tsconfig.compilerOptions.paths).toEqual({
[libName]: [`packages/${libName}/src/index.ts`],
[`@${wsName}/${libName}`]: [`packages/${libName}/src/index.ts`],
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "<%= formattedNames.fileName %>",
"name": "@<%= formattedNames.fileName %>/source",
"version": "0.0.0",
"license": "MIT",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ describe('@nx/workspace:generateWorkspaceFiles', () => {
"nx": "0.0.1",
},
"license": "MIT",
"name": "proj",
"name": "@proj/source",
"private": true,
"scripts": {},
"version": "0.0.0",
Expand Down Expand Up @@ -256,7 +256,7 @@ describe('@nx/workspace:generateWorkspaceFiles', () => {
"nx": "0.0.1",
},
"license": "MIT",
"name": "proj",
"name": "@proj/source",
"private": true,
"scripts": {},
"version": "0.0.0",
Expand Down

0 comments on commit f22c63d

Please sign in to comment.