Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bundling): do not add types field in package.json for esbuild #12424

Merged
merged 1 commit into from Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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',
});
});
});