diff --git a/tools/generators/helpers/packageGenerator.ts b/tools/generators/helpers/packageGenerator.ts index d5318403..336c96b4 100644 --- a/tools/generators/helpers/packageGenerator.ts +++ b/tools/generators/helpers/packageGenerator.ts @@ -16,7 +16,7 @@ interface PackageGeneratorParams { sourcePath: string; packageJson: (options: NormalizedSchema) => PackageJson; packageProjectJson: (root: string) => ProjectConfiguration; - packageTsConfig: TsConfig; + packageTsConfig: (options: NormalizedSchema) => TsConfig; } export const packageGenerator = ({ @@ -35,7 +35,11 @@ export const packageGenerator = ({ packageJson(options), ); - writeJson(tree, join(options.packageRoot, `tsconfig.json`), packageTsConfig); + writeJson( + tree, + join(options.packageRoot, `tsconfig.json`), + packageTsConfig(options), + ); const projectConfiguration = packageProjectJson(options.packageRoot); addProjectConfiguration(tree, options.importPath, projectConfiguration); diff --git a/tools/generators/library/files/.eslintrc.js b/tools/generators/library/files/.eslintrc.js__tmpl__ similarity index 58% rename from tools/generators/library/files/.eslintrc.js rename to tools/generators/library/files/.eslintrc.js__tmpl__ index 028298d8..756bef19 100644 --- a/tools/generators/library/files/.eslintrc.js +++ b/tools/generators/library/files/.eslintrc.js__tmpl__ @@ -1,4 +1,4 @@ -const generateImportOrderRule = require('../../commonConfiguration/generateImportOrderRule'); +const generateImportOrderRule = require('<%= offsetFromRoot %>/commonConfiguration/generateImportOrderRule'); module.exports = { rules: generateImportOrderRule(__dirname), diff --git a/tools/generators/library/files/.lintstagedrc.js__tmpl__ b/tools/generators/library/files/.lintstagedrc.js__tmpl__ index 3b8f90c5..031cc5d3 100644 --- a/tools/generators/library/files/.lintstagedrc.js__tmpl__ +++ b/tools/generators/library/files/.lintstagedrc.js__tmpl__ @@ -1,2 +1,2 @@ -const baseConfig = require('../../.lintstagedrc.js'); +const baseConfig = require('<%= offsetFromRoot %>/.lintstagedrc.js'); module.exports = baseConfig; diff --git a/tools/generators/library/files/babel.config.js b/tools/generators/library/files/babel.config.js deleted file mode 100644 index 31b1233b..00000000 --- a/tools/generators/library/files/babel.config.js +++ /dev/null @@ -1,3 +0,0 @@ -const commonBabelConfig = require('../../commonConfiguration/babel.config'); - -module.exports = commonBabelConfig(); diff --git a/tools/generators/library/files/babel.config.js__tmpl__ b/tools/generators/library/files/babel.config.js__tmpl__ new file mode 100644 index 00000000..929609ce --- /dev/null +++ b/tools/generators/library/files/babel.config.js__tmpl__ @@ -0,0 +1,3 @@ +const commonBabelConfig = require('<%= offsetFromRoot %>/commonConfiguration/babel.config'); + +module.exports = commonBabelConfig(); diff --git a/tools/generators/library/typed-json-config/tsconfig.json.ts b/tools/generators/library/typed-json-config/tsconfig.json.ts index 8844380e..42d247b4 100644 --- a/tools/generators/library/typed-json-config/tsconfig.json.ts +++ b/tools/generators/library/typed-json-config/tsconfig.json.ts @@ -1,7 +1,9 @@ -import { TsConfig } from '../../types'; +import { joinPathFragments } from '@nrwl/devkit'; -export const packageTsConfig: TsConfig = { - extends: '../../tsconfig.json', +import { NormalizedSchema, TsConfig } from '../../types'; + +export const packageTsConfig = (options: NormalizedSchema): TsConfig => ({ + extends: joinPathFragments(options.offsetFromRoot, 'tsconfig.json'), compilerOptions: { baseUrl: 'src', composite: true, @@ -12,4 +14,4 @@ export const packageTsConfig: TsConfig = { }, exclude: ['./dist'], include: ['./**/*.ts'], -}; +}); diff --git a/tools/generators/service/files/.eslintrc.js__tmpl__ b/tools/generators/service/files/.eslintrc.js__tmpl__ index 028298d8..756bef19 100644 --- a/tools/generators/service/files/.eslintrc.js__tmpl__ +++ b/tools/generators/service/files/.eslintrc.js__tmpl__ @@ -1,4 +1,4 @@ -const generateImportOrderRule = require('../../commonConfiguration/generateImportOrderRule'); +const generateImportOrderRule = require('<%= offsetFromRoot %>/commonConfiguration/generateImportOrderRule'); module.exports = { rules: generateImportOrderRule(__dirname), diff --git a/tools/generators/service/files/.lintstagedrc.js__tmpl__ b/tools/generators/service/files/.lintstagedrc.js__tmpl__ index 3b8f90c5..031cc5d3 100644 --- a/tools/generators/service/files/.lintstagedrc.js__tmpl__ +++ b/tools/generators/service/files/.lintstagedrc.js__tmpl__ @@ -1,2 +1,2 @@ -const baseConfig = require('../../.lintstagedrc.js'); +const baseConfig = require('<%= offsetFromRoot %>/.lintstagedrc.js'); module.exports = baseConfig; diff --git a/tools/generators/service/typed-json-config/tsconfig.json.ts b/tools/generators/service/typed-json-config/tsconfig.json.ts index 86c4f253..0db31633 100644 --- a/tools/generators/service/typed-json-config/tsconfig.json.ts +++ b/tools/generators/service/typed-json-config/tsconfig.json.ts @@ -1,20 +1,42 @@ -import { TsConfig } from '../../types'; +import { joinPathFragments } from '@nrwl/devkit'; -export const packageTsConfig: TsConfig = { - extends: '../../tsconfig.json', +import { NormalizedSchema, TsConfig } from '../../types'; + +export const packageTsConfig = (options: NormalizedSchema): TsConfig => ({ + extends: joinPathFragments(options.offsetFromRoot, 'tsconfig.json'), compilerOptions: { preserveSymlinks: true, baseUrl: '.', esModuleInterop: true, }, references: [ - { path: '../../contracts/core-contracts/tsconfig.build.json' }, - { path: '../../packages/configuration/tsconfig.build.json' }, - { path: '../../packages/serverless-configuration/tsconfig.build.json' }, - { path: '../../packages/serverless-helpers/tsconfig.build.json' }, + { + path: joinPathFragments( + options.offsetFromRoot, + 'contracts/core-contracts/tsconfig.build.json', + ), + }, + { + path: joinPathFragments( + options.offsetFromRoot, + 'packages/configuration/tsconfig.build.json', + ), + }, + { + path: joinPathFragments( + options.offsetFromRoot, + 'packages/serverless-configuration/tsconfig.build.json', + ), + }, + { + path: joinPathFragments( + options.offsetFromRoot, + 'packages/serverless-helpers/tsconfig.build.json', + ), + }, ], include: ['./**/*.ts'], 'ts-node': { files: true, }, -}; +});