@nx/js 16.7.0-beta.3 → 16.7.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/generators.json +1 -1
- package/package.json +7 -7
- package/src/executors/swc/swc.impl.js +17 -6
- package/src/generators/library/library.d.ts +5 -3
- package/src/generators/library/library.js +99 -103
- package/src/generators/library/schema.json +6 -1
- package/src/utils/schema.d.ts +2 -0
- package/src/utils/swc/compile-swc.js +3 -2
package/generators.json
CHANGED
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"generators": {
|
|
40
40
|
"library": {
|
|
41
|
-
"factory": "./src/generators/library/library#
|
|
41
|
+
"factory": "./src/generators/library/library#libraryGeneratorInternal",
|
|
42
42
|
"schema": "./src/generators/library/schema.json",
|
|
43
43
|
"aliases": ["lib"],
|
|
44
44
|
"x-type": "library",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "16.7.0-beta.
|
|
3
|
+
"version": "16.7.0-beta.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The JS plugin for Nx contains executors and generators that provide the best experience for developing JavaScript and TypeScript projects. ",
|
|
6
6
|
"repository": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"Tsc",
|
|
17
17
|
"CLI"
|
|
18
18
|
],
|
|
19
|
-
"main": "src/index.js",
|
|
19
|
+
"main": "./src/index.js",
|
|
20
20
|
"typings": "src/index.d.ts",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"bugs": {
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"@babel/preset-env": "^7.22.9",
|
|
40
40
|
"@babel/preset-typescript": "^7.22.5",
|
|
41
41
|
"@babel/runtime": "^7.22.6",
|
|
42
|
-
"@nrwl/js": "16.7.0-beta.
|
|
43
|
-
"@nx/devkit": "16.7.0-beta.
|
|
44
|
-
"@nx/workspace": "16.7.0-beta.
|
|
42
|
+
"@nrwl/js": "16.7.0-beta.5",
|
|
43
|
+
"@nx/devkit": "16.7.0-beta.5",
|
|
44
|
+
"@nx/workspace": "16.7.0-beta.5",
|
|
45
45
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
46
46
|
"babel-plugin-const-enum": "^1.0.1",
|
|
47
47
|
"babel-plugin-macros": "^2.8.0",
|
|
@@ -70,6 +70,6 @@
|
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
|
-
"
|
|
74
|
-
"gitHead": "
|
|
73
|
+
"type": "commonjs",
|
|
74
|
+
"gitHead": "fa513731d4e6a960f112a5af6b0d725b2e624b36"
|
|
75
75
|
}
|
|
@@ -36,12 +36,18 @@ function normalizeOptions(options, root, sourceRoot, projectRoot) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
const files = (0, assets_1.assetGlobsToFiles)(options.assets, root, outputPath);
|
|
39
|
+
const projectRootParts = projectRoot.split('/');
|
|
40
|
+
// We pop the last part of the `projectRoot` to pass
|
|
41
|
+
// the last part (projectDir) and the remainder (projectRootParts) to swc
|
|
42
|
+
const projectDir = projectRootParts.pop();
|
|
43
|
+
// default to current directory if projectRootParts is [].
|
|
44
|
+
// Eg: when a project is at the root level, outside of layout dir
|
|
45
|
+
const swcCwd = projectRootParts.join('/') || '.';
|
|
39
46
|
const swcrcPath = (0, get_swcrc_path_1.getSwcrcPath)(options, root, projectRoot);
|
|
40
|
-
// TODO(meeroslav): Check why this is needed in order for swc to properly nest folders
|
|
41
|
-
const distParent = outputPath.split('/').slice(0, -1).join('/');
|
|
42
47
|
const swcCliOptions = {
|
|
43
|
-
srcPath:
|
|
44
|
-
destPath: (0, path_1.relative)(root,
|
|
48
|
+
srcPath: projectDir,
|
|
49
|
+
destPath: (0, path_1.relative)((0, path_1.join)(root, swcCwd), outputPath),
|
|
50
|
+
swcCwd,
|
|
45
51
|
swcrcPath,
|
|
46
52
|
};
|
|
47
53
|
return Object.assign(Object.assign({}, options), { mainOutputPath: (0, path_1.resolve)(outputPath, options.main.replace(`${projectRoot}/`, '').replace('.ts', '.js')), files,
|
|
@@ -64,8 +70,13 @@ function swcExecutor(_options, context) {
|
|
|
64
70
|
const inlineProjectGraph = (0, inline_1.handleInliningBuild)(context, options, options.tsConfig);
|
|
65
71
|
if (!(0, inline_1.isInlineGraphEmpty)(inlineProjectGraph)) {
|
|
66
72
|
options.projectRoot = '.'; // set to root of workspace to include other libs for type check
|
|
67
|
-
|
|
68
|
-
options.swcCliOptions.
|
|
73
|
+
// remap paths for SWC compilation
|
|
74
|
+
options.swcCliOptions.srcPath = options.swcCliOptions.swcCwd;
|
|
75
|
+
options.swcCliOptions.swcCwd = '.';
|
|
76
|
+
options.swcCliOptions.destPath = options.swcCliOptions.destPath
|
|
77
|
+
.split('../')
|
|
78
|
+
.at(-1)
|
|
79
|
+
.concat('/', options.swcCliOptions.srcPath);
|
|
69
80
|
// tmp swcrc with dependencies to exclude
|
|
70
81
|
// - buildable libraries
|
|
71
82
|
// - other libraries that are not dependent on the current project
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
|
+
import { type ProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
3
|
import { LibraryGeneratorSchema } from '../../utils/schema';
|
|
3
4
|
export declare function libraryGenerator(tree: Tree, schema: LibraryGeneratorSchema): Promise<GeneratorCallback>;
|
|
4
|
-
export declare function
|
|
5
|
+
export declare function libraryGeneratorInternal(tree: Tree, schema: LibraryGeneratorSchema): Promise<GeneratorCallback>;
|
|
5
6
|
export interface NormalizedSchema extends LibraryGeneratorSchema {
|
|
6
7
|
name: string;
|
|
8
|
+
projectNames: ProjectNameAndRootOptions['names'];
|
|
7
9
|
fileName: string;
|
|
8
10
|
projectRoot: string;
|
|
9
|
-
projectDirectory: string;
|
|
10
11
|
parsedTags: string[];
|
|
11
12
|
importPath?: string;
|
|
12
13
|
}
|
|
13
|
-
export
|
|
14
|
+
export type AddLintOptions = Pick<NormalizedSchema, 'name' | 'linter' | 'projectRoot' | 'unitTestRunner' | 'js' | 'setParserOptionsProject' | 'rootProject'>;
|
|
15
|
+
export declare function addLint(tree: Tree, options: AddLintOptions): Promise<GeneratorCallback>;
|
|
14
16
|
export default libraryGenerator;
|
|
15
17
|
export declare const librarySchematic: (generatorOptions: LibraryGeneratorSchema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -1,36 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.librarySchematic = exports.addLint = exports.
|
|
3
|
+
exports.librarySchematic = exports.addLint = exports.libraryGeneratorInternal = exports.libraryGenerator = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
7
|
const ts_config_1 = require("../../utils/typescript/ts-config");
|
|
7
8
|
const path_1 = require("path");
|
|
8
9
|
const minimal_publish_script_1 = require("../../utils/minimal-publish-script");
|
|
9
10
|
const add_swc_config_1 = require("../../utils/swc/add-swc-config");
|
|
10
11
|
const add_swc_dependencies_1 = require("../../utils/swc/add-swc-dependencies");
|
|
11
|
-
const get_import_path_1 = require("../../utils/get-import-path");
|
|
12
12
|
const versions_1 = require("../../utils/versions");
|
|
13
13
|
const init_1 = require("../init/init");
|
|
14
14
|
const generator_1 = require("../setup-verdaccio/generator");
|
|
15
15
|
const create_ts_config_1 = require("../../utils/typescript/create-ts-config");
|
|
16
16
|
function libraryGenerator(tree, schema) {
|
|
17
17
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
: layoutDirectory !== null && layoutDirectory !== void 0 ? layoutDirectory : (0, devkit_1.getWorkspaceLayout)(tree).libsDir;
|
|
23
|
-
return projectGenerator(tree, schema, libsDir, (0, path_1.join)(__dirname, './files'));
|
|
18
|
+
return yield libraryGeneratorInternal(tree, Object.assign({
|
|
19
|
+
// provide a default projectNameAndRootFormat to avoid breaking changes
|
|
20
|
+
// to external generators invoking this one
|
|
21
|
+
projectNameAndRootFormat: 'derived' }, schema));
|
|
24
22
|
});
|
|
25
23
|
}
|
|
26
24
|
exports.libraryGenerator = libraryGenerator;
|
|
27
|
-
function
|
|
25
|
+
function libraryGeneratorInternal(tree, schema) {
|
|
28
26
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const filesDir = (0, path_1.join)(__dirname, './files');
|
|
29
28
|
const tasks = [];
|
|
30
29
|
tasks.push(yield (0, init_1.default)(tree, Object.assign(Object.assign({}, schema), { skipFormat: true, tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json' })));
|
|
31
|
-
const options = normalizeOptions(tree, schema
|
|
30
|
+
const options = yield normalizeOptions(tree, schema);
|
|
32
31
|
createFiles(tree, options, `${filesDir}/lib`);
|
|
33
|
-
addProject(tree, options
|
|
32
|
+
addProject(tree, options);
|
|
34
33
|
tasks.push(addProjectDependencies(tree, options));
|
|
35
34
|
if (options.publishable) {
|
|
36
35
|
tasks.push(yield (0, generator_1.default)(tree, Object.assign(Object.assign({}, options), { skipFormat: true })));
|
|
@@ -86,8 +85,8 @@ function projectGenerator(tree, schema, destinationDir, filesDir) {
|
|
|
86
85
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
87
86
|
});
|
|
88
87
|
}
|
|
89
|
-
exports.
|
|
90
|
-
function addProject(tree, options
|
|
88
|
+
exports.libraryGeneratorInternal = libraryGeneratorInternal;
|
|
89
|
+
function addProject(tree, options) {
|
|
91
90
|
var _a;
|
|
92
91
|
var _b;
|
|
93
92
|
const projectConfiguration = {
|
|
@@ -100,7 +99,7 @@ function addProject(tree, options, destinationDir) {
|
|
|
100
99
|
if (options.bundler &&
|
|
101
100
|
options.bundler !== 'none' &&
|
|
102
101
|
options.config !== 'npm-scripts') {
|
|
103
|
-
const outputPath = getOutputPath(options
|
|
102
|
+
const outputPath = getOutputPath(options);
|
|
104
103
|
projectConfiguration.targets.build = {
|
|
105
104
|
executor: getBuildExecutor(options.bundler),
|
|
106
105
|
outputs: ['{options.outputPath}'],
|
|
@@ -212,7 +211,7 @@ function addBabelRc(tree, options) {
|
|
|
212
211
|
(0, devkit_1.writeJson)(tree, (0, path_1.join)(options.projectRoot, filename), babelrc);
|
|
213
212
|
}
|
|
214
213
|
function createFiles(tree, options, filesDir) {
|
|
215
|
-
const { className, name, propertyName } = (0, devkit_1.names)(options.
|
|
214
|
+
const { className, name, propertyName } = (0, devkit_1.names)(options.projectNames.projectFileName);
|
|
216
215
|
createProjectTsConfigJson(tree, options);
|
|
217
216
|
(0, devkit_1.generateFiles)(tree, filesDir, options.projectRoot, Object.assign(Object.assign({}, options), { dot: '.', className,
|
|
218
217
|
name,
|
|
@@ -290,90 +289,90 @@ function replaceJestConfig(tree, options, filesDir) {
|
|
|
290
289
|
testEnvironment: options.testEnvironment,
|
|
291
290
|
});
|
|
292
291
|
}
|
|
293
|
-
function normalizeOptions(tree, options
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
options.config
|
|
320
|
-
|
|
321
|
-
if (options.publishable) {
|
|
322
|
-
if (!options.importPath) {
|
|
323
|
-
throw new Error(`For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)`);
|
|
292
|
+
function normalizeOptions(tree, options) {
|
|
293
|
+
var _a, _b, _c;
|
|
294
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
295
|
+
/**
|
|
296
|
+
* We are deprecating the compiler and the buildable options.
|
|
297
|
+
* However, we want to keep the existing behavior for now.
|
|
298
|
+
*
|
|
299
|
+
* So, if the user has not provided a bundler, we will use the compiler option, if any.
|
|
300
|
+
*
|
|
301
|
+
* If the user has not provided a bundler and no compiler, but has set buildable to true,
|
|
302
|
+
* we will use tsc, since that is the compiler the old generator used to default to, if buildable was true
|
|
303
|
+
* and no compiler was provided.
|
|
304
|
+
*
|
|
305
|
+
* If the user has not provided a bundler and no compiler, and has not set buildable to true, then
|
|
306
|
+
* set the bundler to tsc, to preserve old default behaviour (buildable: true by default).
|
|
307
|
+
*
|
|
308
|
+
* If it's publishable, we need to build the code before publishing it, so again
|
|
309
|
+
* we default to `tsc`. In the previous version of this, it would set `buildable` to true
|
|
310
|
+
* and that would default to `tsc`.
|
|
311
|
+
*
|
|
312
|
+
* In the past, the only way to get a non-buildable library was to set buildable to false.
|
|
313
|
+
* Now, the only way to get a non-buildble library is to set bundler to none.
|
|
314
|
+
* By default, with nothing provided, libraries are buildable with `@nx/js:tsc`.
|
|
315
|
+
*/
|
|
316
|
+
options.bundler = (_b = (_a = options.bundler) !== null && _a !== void 0 ? _a : options.compiler) !== null && _b !== void 0 ? _b : 'tsc';
|
|
317
|
+
// ensure programmatic runs have an expected default
|
|
318
|
+
if (!options.config) {
|
|
319
|
+
options.config = 'project';
|
|
324
320
|
}
|
|
325
|
-
if (options.
|
|
326
|
-
options.
|
|
321
|
+
if (options.publishable) {
|
|
322
|
+
if (!options.importPath) {
|
|
323
|
+
throw new Error(`For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)`);
|
|
324
|
+
}
|
|
325
|
+
if (options.bundler === 'none') {
|
|
326
|
+
options.bundler = 'tsc';
|
|
327
|
+
}
|
|
327
328
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
329
|
+
// This is to preserve old behaviour, buildable: false
|
|
330
|
+
if (options.publishable === false && options.buildable === false) {
|
|
331
|
+
options.bundler = 'none';
|
|
332
|
+
}
|
|
333
|
+
const { Linter } = (0, devkit_1.ensurePackage)('@nx/linter', versions_1.nxVersion);
|
|
334
|
+
if (options.config === 'npm-scripts') {
|
|
335
|
+
options.unitTestRunner = 'none';
|
|
336
|
+
options.linter = Linter.None;
|
|
337
|
+
options.bundler = 'none';
|
|
338
|
+
}
|
|
339
|
+
if ((options.bundler === 'swc' || options.bundler === 'rollup') &&
|
|
340
|
+
options.skipTypeCheck == null) {
|
|
341
|
+
options.skipTypeCheck = false;
|
|
342
|
+
}
|
|
343
|
+
if (!options.unitTestRunner && options.bundler === 'vite') {
|
|
344
|
+
options.unitTestRunner = 'vitest';
|
|
345
|
+
}
|
|
346
|
+
else if (!options.unitTestRunner && options.config !== 'npm-scripts') {
|
|
347
|
+
options.unitTestRunner = 'jest';
|
|
348
|
+
}
|
|
349
|
+
if (!options.linter && options.config !== 'npm-scripts') {
|
|
350
|
+
options.linter = Linter.EsLint;
|
|
351
|
+
}
|
|
352
|
+
const { projectName, names: projectNames, projectRoot, importPath, } = yield (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
|
353
|
+
name: options.name,
|
|
354
|
+
projectType: 'library',
|
|
355
|
+
directory: options.directory,
|
|
356
|
+
importPath: options.importPath,
|
|
357
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
358
|
+
rootProject: options.rootProject,
|
|
359
|
+
});
|
|
360
|
+
options.rootProject = projectRoot === '.';
|
|
361
|
+
const fileName = getCaseAwareFileName({
|
|
362
|
+
fileName: options.simpleName
|
|
363
|
+
? projectNames.projectSimpleName
|
|
364
|
+
: projectNames.projectFileName,
|
|
365
|
+
pascalCaseFiles: options.pascalCaseFiles,
|
|
366
|
+
});
|
|
367
|
+
const parsedTags = options.tags
|
|
368
|
+
? options.tags.split(',').map((s) => s.trim())
|
|
369
|
+
: [];
|
|
370
|
+
(_c = options.minimal) !== null && _c !== void 0 ? _c : (options.minimal = false);
|
|
371
|
+
return Object.assign(Object.assign({}, options), { fileName, name: projectName, projectNames,
|
|
372
|
+
projectRoot,
|
|
373
|
+
parsedTags,
|
|
374
|
+
importPath });
|
|
364
375
|
});
|
|
365
|
-
const projectRoot = (0, devkit_1.joinPathFragments)(destinationDir, projectDirectory);
|
|
366
|
-
const parsedTags = options.tags
|
|
367
|
-
? options.tags.split(',').map((s) => s.trim())
|
|
368
|
-
: [];
|
|
369
|
-
const importPath = options.rootProject
|
|
370
|
-
? (_c = (0, devkit_1.readJson)(tree, 'package.json').name) !== null && _c !== void 0 ? _c : (0, get_import_path_1.getImportPath)(tree, 'core')
|
|
371
|
-
: options.importPath || (0, get_import_path_1.getImportPath)(tree, projectDirectory);
|
|
372
|
-
(_d = options.minimal) !== null && _d !== void 0 ? _d : (options.minimal = false);
|
|
373
|
-
return Object.assign(Object.assign({}, options), { fileName, name: projectName, projectRoot,
|
|
374
|
-
projectDirectory,
|
|
375
|
-
parsedTags,
|
|
376
|
-
importPath });
|
|
377
376
|
}
|
|
378
377
|
function getCaseAwareFileName(options) {
|
|
379
378
|
const normalized = (0, devkit_1.names)(options.fileName);
|
|
@@ -413,16 +412,13 @@ function getBuildExecutor(bundler) {
|
|
|
413
412
|
return undefined;
|
|
414
413
|
}
|
|
415
414
|
}
|
|
416
|
-
function getOutputPath(options
|
|
415
|
+
function getOutputPath(options) {
|
|
417
416
|
const parts = ['dist'];
|
|
418
|
-
if (
|
|
419
|
-
parts.push(destinationDir);
|
|
420
|
-
}
|
|
421
|
-
if (options.projectDirectory === '.') {
|
|
417
|
+
if (options.projectRoot === '.') {
|
|
422
418
|
parts.push(options.name);
|
|
423
419
|
}
|
|
424
420
|
else {
|
|
425
|
-
parts.push(options.
|
|
421
|
+
parts.push(options.projectRoot);
|
|
426
422
|
}
|
|
427
423
|
return (0, devkit_1.joinPathFragments)(...parts);
|
|
428
424
|
}
|
|
@@ -506,4 +502,4 @@ function determineEntryFields(options) {
|
|
|
506
502
|
}
|
|
507
503
|
}
|
|
508
504
|
exports.default = libraryGenerator;
|
|
509
|
-
exports.librarySchematic = (0, devkit_1.convertNxGenerator)(
|
|
505
|
+
exports.librarySchematic = (0, devkit_1.convertNxGenerator)(libraryGeneratorInternal);
|
|
@@ -14,13 +14,18 @@
|
|
|
14
14
|
"index": 0
|
|
15
15
|
},
|
|
16
16
|
"x-prompt": "What name would you like to use for the library?",
|
|
17
|
-
"pattern": "
|
|
17
|
+
"pattern": "(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$"
|
|
18
18
|
},
|
|
19
19
|
"directory": {
|
|
20
20
|
"type": "string",
|
|
21
21
|
"description": "A directory where the lib is placed.",
|
|
22
22
|
"x-priority": "important"
|
|
23
23
|
},
|
|
24
|
+
"projectNameAndRootFormat": {
|
|
25
|
+
"description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
|
|
26
|
+
"type": "string",
|
|
27
|
+
"enum": ["as-provided", "derived"]
|
|
28
|
+
},
|
|
24
29
|
"linter": {
|
|
25
30
|
"description": "The tool to use for running lint checks.",
|
|
26
31
|
"type": "string",
|
package/src/utils/schema.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-directory-utils';
|
|
1
2
|
// nx-ignore-next-line
|
|
2
3
|
const { Linter } = require('@nx/linter'); // use require to import to avoid circular dependency
|
|
3
4
|
import type { AssetGlob, FileInputOutput } from './assets/assets';
|
|
@@ -9,6 +10,7 @@ export type Bundler = 'swc' | 'tsc' | 'rollup' | 'vite' | 'esbuild' | 'none';
|
|
|
9
10
|
export interface LibraryGeneratorSchema {
|
|
10
11
|
name: string;
|
|
11
12
|
directory?: string;
|
|
13
|
+
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
12
14
|
skipFormat?: boolean;
|
|
13
15
|
tags?: string;
|
|
14
16
|
skipTsConfig?: boolean;
|
|
@@ -9,8 +9,8 @@ const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
|
9
9
|
const print_diagnostics_1 = require("../typescript/print-diagnostics");
|
|
10
10
|
const run_type_check_1 = require("../typescript/run-type-check");
|
|
11
11
|
function getSwcCmd({ swcrcPath, srcPath, destPath }, watch = false) {
|
|
12
|
-
const
|
|
13
|
-
let swcCmd = `${
|
|
12
|
+
const swcCLI = require.resolve('@swc/cli/bin/swc.js');
|
|
13
|
+
let swcCmd = `${swcCLI} ${
|
|
14
14
|
// TODO(jack): clean this up when we remove inline module support
|
|
15
15
|
// Handle root project
|
|
16
16
|
srcPath === '.' ? 'src' : srcPath} -d ${srcPath === '.' ? `${destPath}/src` : destPath} --config-file=${swcrcPath}`;
|
|
@@ -39,6 +39,7 @@ function compileSwc(context, normalizedOptions, postCompilationCallback) {
|
|
|
39
39
|
}
|
|
40
40
|
const swcCmdLog = (0, child_process_1.execSync)(getSwcCmd(normalizedOptions.swcCliOptions), {
|
|
41
41
|
encoding: 'utf8',
|
|
42
|
+
cwd: normalizedOptions.swcCliOptions.swcCwd,
|
|
42
43
|
});
|
|
43
44
|
devkit_1.logger.log(swcCmdLog.replace(/\n/, ''));
|
|
44
45
|
const isCompileSuccess = swcCmdLog.includes('Successfully compiled');
|