diff --git a/packages/node/src/generators/library/library.spec.ts b/packages/node/src/generators/library/library.spec.ts index 6a1ceb68ce2ac0..b4e5a051cf3472 100644 --- a/packages/node/src/generators/library/library.spec.ts +++ b/packages/node/src/generators/library/library.spec.ts @@ -633,5 +633,49 @@ describe('lib', () => { } `); }); + + it('should set correct options for swc', async () => { + await libraryGenerator(tree, { + directory: 'mylib', + buildable: true, + compiler: 'swc', + unitTestRunner: 'jest', + addPlugin: true, + } as Schema); + + expect(readJson(tree, 'mylib/package.json')).toMatchInlineSnapshot(` + { + "dependencies": { + "tslib": "^2.3.0", + }, + "main": "./dist/index.js", + "name": "@proj/mylib", + "nx": { + "name": "mylib", + "projectType": "library", + "sourceRoot": "mylib/src", + "targets": { + "build": { + "executor": "@nx/js:swc", + "options": { + "main": "mylib/src/index.ts", + "outputPath": "mylib/dist", + "packageJson": "mylib/package.json", + "stripLeadingPaths": true, + "tsConfig": "mylib/tsconfig.lib.json", + }, + "outputs": [ + "{options.outputPath}", + ], + }, + }, + }, + "private": true, + "type": "commonjs", + "typings": "./dist/index.d.ts", + "version": "0.0.1", + } + `); + }); }); }); diff --git a/packages/node/src/generators/library/library.ts b/packages/node/src/generators/library/library.ts index 9eafb677ed9bea..68a3dcdbc7c60f 100644 --- a/packages/node/src/generators/library/library.ts +++ b/packages/node/src/generators/library/library.ts @@ -198,14 +198,19 @@ function updateProject(tree: Tree, options: NormalizedSchema) { executor: `@nx/js:${options.compiler}`, outputs: ['{options.outputPath}'], options: { - outputPath: joinPathFragments( - 'dist', - rootProject ? options.projectName : options.projectRoot - ), + outputPath: options.isUsingTsSolutionConfig + ? joinPathFragments(options.projectRoot, 'dist') + : joinPathFragments( + 'dist', + rootProject ? options.projectName : options.projectRoot + ), tsConfig: `${options.projectRoot}/tsconfig.lib.json`, packageJson: `${options.projectRoot}/package.json`, main: `${options.projectRoot}/src/index` + (options.js ? '.js' : '.ts'), - assets: [`${options.projectRoot}/*.md`], + assets: options.isUsingTsSolutionConfig + ? undefined + : [`${options.projectRoot}/*.md`], + stripLeadingPaths: options.isUsingTsSolutionConfig ? true : undefined, }, }; } diff --git a/packages/nuxt/src/generators/application/__snapshots__/application.spec.ts.snap b/packages/nuxt/src/generators/application/__snapshots__/application.spec.ts.snap index 67c3d76774431b..f080ce37ee7980 100644 --- a/packages/nuxt/src/generators/application/__snapshots__/application.spec.ts.snap +++ b/packages/nuxt/src/generators/application/__snapshots__/application.spec.ts.snap @@ -108,7 +108,6 @@ exports[`app generated files content - as-provided - my-app general application exports[`app generated files content - as-provided - my-app general application should configure tsconfig and project.json correctly 2`] = ` "{ - "compilerOptions": {}, "files": [], "include": [".nuxt/nuxt.d.ts"], "references": [ @@ -190,7 +189,6 @@ exports[`app generated files content - as-provided - my-app general application exports[`app generated files content - as-provided - my-app general application should configure vitest correctly 3`] = ` "{ - "compilerOptions": {}, "files": [], "include": [".nuxt/nuxt.d.ts"], "references": [ @@ -469,7 +467,6 @@ exports[`app generated files content - as-provided - myApp general application s exports[`app generated files content - as-provided - myApp general application should configure tsconfig and project.json correctly 2`] = ` "{ - "compilerOptions": {}, "files": [], "include": [".nuxt/nuxt.d.ts"], "references": [ @@ -551,7 +548,6 @@ exports[`app generated files content - as-provided - myApp general application s exports[`app generated files content - as-provided - myApp general application should configure vitest correctly 3`] = ` "{ - "compilerOptions": {}, "files": [], "include": [".nuxt/nuxt.d.ts"], "references": [ diff --git a/packages/nuxt/src/generators/application/application.spec.ts b/packages/nuxt/src/generators/application/application.spec.ts index 387ea579e63111..c7499e30f435ac 100644 --- a/packages/nuxt/src/generators/application/application.spec.ts +++ b/packages/nuxt/src/generators/application/application.spec.ts @@ -244,7 +244,6 @@ describe('app', () => { `); expect(readJson(tree, 'myapp/tsconfig.json')).toMatchInlineSnapshot(` { - "compilerOptions": {}, "extends": "../tsconfig.base.json", "files": [], "include": [ diff --git a/packages/nuxt/src/utils/create-ts-config.ts b/packages/nuxt/src/utils/create-ts-config.ts index 46e9ed6ce268ef..4da5da76f10435 100644 --- a/packages/nuxt/src/utils/create-ts-config.ts +++ b/packages/nuxt/src/utils/create-ts-config.ts @@ -12,7 +12,6 @@ export function createTsConfig( ) { createAppTsConfig(host, options); const json = { - compilerOptions: {}, files: [], include: ['.nuxt/nuxt.d.ts'], references: [ diff --git a/packages/vue/src/generators/library/lib/create-library-files.ts b/packages/vue/src/generators/library/lib/create-library-files.ts index ae1d352b756ba8..323a3d80f551bc 100644 --- a/packages/vue/src/generators/library/lib/create-library-files.ts +++ b/packages/vue/src/generators/library/lib/create-library-files.ts @@ -44,6 +44,7 @@ export function createLibraryFiles(host: Tree, options: NormalizedSchema) { '.': { import: './index.mjs', require: './index.js', + types: './index.d.ts', }, }, }); diff --git a/packages/vue/src/utils/create-ts-config.ts b/packages/vue/src/utils/create-ts-config.ts index 9179cac644843e..406db47a37c0ce 100644 --- a/packages/vue/src/utils/create-ts-config.ts +++ b/packages/vue/src/utils/create-ts-config.ts @@ -16,13 +16,7 @@ export function createTsConfig( relativePathToRootTsConfig: string ) { if (isUsingTsSolutionSetup(host)) { - createTsConfigForTsSolution( - host, - projectRoot, - type, - options, - relativePathToRootTsConfig - ); + createTsConfigForTsSolution(host, projectRoot, type, options); } else { createTsConfigForNonTsSolution( host, @@ -43,8 +37,7 @@ export function createTsConfigForTsSolution( style?: string; rootProject?: boolean; unitTestRunner?: string; - }, - relativePathToRootTsConfig: string + } ) { const json = { files: [], @@ -56,18 +49,6 @@ export function createTsConfigForTsSolution( ], } as any; - // inline tsconfig.base.json into the project - if (options.rootProject) { - json.compileOnSave = false; - json.compilerOptions = { - ...shared.tsConfigBaseOptions, - ...json.compilerOptions, - }; - json.exclude = ['node_modules', 'tmp']; - } else { - json.extends = relativePathToRootTsConfig; - } - writeJson(host, `${projectRoot}/tsconfig.json`, json); const tsconfigProjectPath = `${projectRoot}/tsconfig.${type}.json`; @@ -82,7 +63,6 @@ export function createTsConfigForTsSolution( return json; }); - } else { } } diff --git a/packages/workspace/src/generators/preset/preset.ts b/packages/workspace/src/generators/preset/preset.ts index f60042302f0bd9..37564d7b1c47ed 100644 --- a/packages/workspace/src/generators/preset/preset.ts +++ b/packages/workspace/src/generators/preset/preset.ts @@ -136,6 +136,7 @@ async function createPreset(tree: Tree, options: Schema) { addPlugin, nxCloudToken: options.nxCloudToken, useTsSolution: options.workspaces, + formatter: options.formatter, }); } else if (options.preset === Preset.VueStandalone) { const { applicationGenerator: vueApplicationGenerator } = require('@nx' + @@ -165,6 +166,7 @@ async function createPreset(tree: Tree, options: Schema) { addPlugin, nxCloudToken: options.nxCloudToken, useTsSolution: options.workspaces, + formatter: options.formatter, }); } else if (options.preset === Preset.NuxtStandalone) { const { applicationGenerator: nuxtApplicationGenerator } = require('@nx' +