Skip to content

Commit

Permalink
fix(bundling): do not add types field in package.json for esbuild (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo committed Oct 5, 2022
1 parent e0d336f commit d904160
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/esbuild/src/executors/esbuild/esbuild.impl.ts
Expand Up @@ -2,7 +2,6 @@ import 'dotenv/config';
import * as chalk from 'chalk';
import type { ExecutorContext } from '@nrwl/devkit';
import { cacheDir, joinPathFragments, logger } from '@nrwl/devkit';
import { parse } from 'path';
import {
copyAssets,
copyPackageJson,
Expand All @@ -18,7 +17,6 @@ import { removeSync, writeJsonSync } from 'fs-extra';
import { createAsyncIterable } from '@nrwl/js/src/utils/create-async-iterable/create-async-iteratable';
import { buildEsbuildOptions } from './lib/build-esbuild-options';

const ESM_FILE_EXTENSION = '.js';
const CJS_FILE_EXTENSION = '.cjs';

const BUILD_WATCH_FAILED = `[ ${chalk.red(
Expand All @@ -40,7 +38,8 @@ export async function* esbuildExecutor(
const packageJsonResult = await copyPackageJson(
{
...options,
skipTypings: options.skipTypeCheck,
// TODO(jack): make types generate with esbuild
skipTypings: true,
outputFileExtensionForCjs: CJS_FILE_EXTENSION,
},
context
Expand Down
21 changes: 21 additions & 0 deletions packages/js/src/utils/package-json/update-package-json.spec.ts
Expand Up @@ -145,4 +145,25 @@ describe('getUpdatedPackageJsonContent', () => {
},
});
});

it('should not set types when { skipTypings: true }', () => {
const json = getUpdatedPackageJsonContent(
{
name: 'test',
version: '0.0.1',
},
{
main: 'proj/src/index.ts',
outputPath: 'dist/proj',
projectRoot: 'proj',
skipTypings: true,
}
);

expect(json).toEqual({
name: 'test',
main: './src/index.js',
version: '0.0.1',
});
});
});

0 comments on commit d904160

Please sign in to comment.