@nx/esbuild 19.0.3 → 19.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/esbuild",
3
- "version": "19.0.3",
3
+ "version": "19.0.5",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for esbuild contains executors and generators that support building applications using esbuild",
6
6
  "repository": {
@@ -34,9 +34,9 @@
34
34
  "fs-extra": "^11.1.0",
35
35
  "tslib": "^2.3.0",
36
36
  "tsconfig-paths": "^4.1.2",
37
- "@nx/devkit": "19.0.3",
38
- "@nx/js": "19.0.3",
39
- "@nrwl/esbuild": "19.0.3"
37
+ "@nx/devkit": "19.0.5",
38
+ "@nx/js": "19.0.5",
39
+ "@nrwl/esbuild": "19.0.5"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "esbuild": "~0.19.2"
@@ -145,12 +145,17 @@ exports.esbuildExecutor = esbuildExecutor;
145
145
  function getTypeCheckOptions(options, context) {
146
146
  const { watch, tsConfig, outputPath } = options;
147
147
  const typeCheckOptions = {
148
- // TODO(jack): Add support for d.ts declaration files -- once the `@nx/js:tsc` changes are in we can use the same logic.
149
- mode: 'noEmit',
148
+ ...(options.declaration
149
+ ? {
150
+ mode: 'emitDeclarationOnly',
151
+ outDir: outputPath,
152
+ }
153
+ : {
154
+ mode: 'noEmit',
155
+ }),
150
156
  tsConfigPath: tsConfig,
151
- // outDir: outputPath,
152
157
  workspaceRoot: context.root,
153
- rootDir: context.root,
158
+ rootDir: options.declarationRootDir ?? context.root,
154
159
  };
155
160
  if (watch) {
156
161
  typeCheckOptions.incremental = true;
@@ -5,7 +5,9 @@ const fs = require("fs");
5
5
  const path = require("path");
6
6
  const devkit_1 = require("@nx/devkit");
7
7
  const chalk = require("chalk");
8
+ const js_1 = require("@nx/js");
8
9
  function normalizeOptions(options, context) {
10
+ const tsConfig = (0, js_1.readTsConfig)(options.tsConfig);
9
11
  // If we're not generating package.json file, then copy it as-is as an asset.
10
12
  const assets = options.generatePackageJson
11
13
  ? options.assets
@@ -17,6 +19,17 @@ function normalizeOptions(options, context) {
17
19
  devkit_1.logger.info(chalk.yellow(`Your build has conflicting options, ${chalk.bold('bundle:false')} and ${chalk.bold('thirdParty:true')}. Your package.json depedencies might not be generated correctly so we added an update ${chalk.bold('thirdParty:false')}`));
18
20
  }
19
21
  const thirdParty = !options.bundle ? false : options.thirdParty;
22
+ const { root: projectRoot } = context.projectsConfigurations.projects[context.projectName];
23
+ const declarationRootDir = options.declarationRootDir
24
+ ? path.join(context.root, options.declarationRootDir)
25
+ : undefined;
26
+ // if option declaration is defined, then it takes precedence over the tsconfig option
27
+ const declaration = options.declaration ??
28
+ (tsConfig.options.declaration || tsConfig.options.composite);
29
+ if (options.skipTypeCheck && declaration) {
30
+ devkit_1.logger.info(chalk.yellow(`Your build has conflicting options, ${chalk.bold('skipTypeCheck:true')} and ${chalk.bold('declaration:true')}. Your declarations won't be generated so we added an update ${chalk.bold('skipTypeCheck:false')}`));
31
+ }
32
+ const skipTypeCheck = declaration ? false : options.skipTypeCheck;
20
33
  let userDefinedBuildOptions;
21
34
  if (options.esbuildConfig) {
22
35
  const userDefinedConfig = path.resolve(context.root, options.esbuildConfig);
@@ -38,6 +51,9 @@ function normalizeOptions(options, context) {
38
51
  ...rest,
39
52
  thirdParty,
40
53
  assets,
54
+ declaration,
55
+ declarationRootDir,
56
+ skipTypeCheck,
41
57
  userDefinedBuildOptions,
42
58
  external: options.external ?? [],
43
59
  singleEntry: false,
@@ -52,6 +68,9 @@ function normalizeOptions(options, context) {
52
68
  ...options,
53
69
  thirdParty,
54
70
  assets,
71
+ declaration,
72
+ declarationRootDir,
73
+ skipTypeCheck,
55
74
  userDefinedBuildOptions,
56
75
  external: options.external ?? [],
57
76
  singleEntry: true,
@@ -7,6 +7,8 @@ export interface EsBuildExecutorOptions {
7
7
  additionalEntryPoints?: string[];
8
8
  assets: (AssetGlob | string)[];
9
9
  bundle?: boolean;
10
+ declaration?: boolean;
11
+ declarationRootDir?: string;
10
12
  deleteOutputPath?: boolean;
11
13
  esbuildOptions?: Record<string, any>;
12
14
  esbuildConfig?: string;
@@ -2,7 +2,7 @@
2
2
  "version": 2,
3
3
  "outputCapture": "direct-nodejs",
4
4
  "title": "esbuild (experimental)",
5
- "description": "Bundle a package for different platforms. Note: declaration (*.d.ts) file are not currently generated.",
5
+ "description": "Bundle a package for different platforms.",
6
6
  "cli": "nx",
7
7
  "type": "object",
8
8
  "properties": {
@@ -54,6 +54,14 @@
54
54
  },
55
55
  "default": ["esm"]
56
56
  },
57
+ "declaration": {
58
+ "type": "boolean",
59
+ "description": "Generate declaration (*.d.ts) files for every TypeScript or JavaScript file inside your project. Should be used for libraries that are published to an npm repository."
60
+ },
61
+ "declarationRootDir": {
62
+ "type": "string",
63
+ "description": "Sets the rootDir for the declaration (*.d.ts) files."
64
+ },
57
65
  "watch": {
58
66
  "type": "boolean",
59
67
  "description": "Enable re-building when files change.",