Skip to content

Commit aa49eb5

Browse files
authored
fix(httpsnippet-client-api): making external deps no longer external (#810)
* fix: marking external esm-only deps as bundled deps * fix: moving camelcase and stringify-object to being devdeps * fix: dont use bundledDependencies
1 parent aa22328 commit aa49eb5

File tree

5 files changed

+29
-11
lines changed

5 files changed

+29
-11
lines changed

package-lock.json

+8-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/tsup.config.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ export default defineConfig((options: Options) => ({
1111
...config,
1212

1313
entry: ['src/errors/fetchError.ts', 'src/lib/index.ts', 'src/index.ts', 'src/types.ts'],
14+
1415
noExternal: [
15-
// `get-stream` is ESM-only and we need to build for CommonJS,
16-
// so including it here means that its (tree-shaken!) source code
17-
// will be included directly in our dist outputs.
16+
// These dependencies are ESM-only but because we're building for ESM **and** CJS we can't
17+
// treat them as external dependencies as CJS libraries can't load ESM code that uses `export`.
18+
// `noExternal` will instead treeshake these dependencies down and include them in our compiled
19+
// dists.
1820
'get-stream',
1921
],
22+
2023
silent: !options.watch,
2124
}));

packages/httpsnippet-client-api/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@
3636
"node": ">=18"
3737
},
3838
"dependencies": {
39-
"camelcase": "^8.0.0",
4039
"content-type": "^1.0.5",
41-
"reserved2": "^0.1.5",
42-
"stringify-object": "^5.0.0"
40+
"reserved2": "^0.1.5"
4341
},
4442
"peerDependencies": {
4543
"@readme/httpsnippet": ">=8.1.2",
@@ -51,6 +49,8 @@
5149
"@types/content-type": "^1.1.6",
5250
"@types/stringify-object": "^4.0.3",
5351
"@vitest/coverage-v8": "^0.34.4",
52+
"camelcase": "^8.0.0",
53+
"stringify-object": "^5.0.0",
5454
"typescript": "^5.2.2",
5555
"vitest": "^0.34.5"
5656
},

packages/httpsnippet-client-api/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import type { Operation } from 'oas/operation';
44
import type { HttpMethods, OASDocument } from 'oas/types';
55

66
import { CodeBuilder } from '@readme/httpsnippet/helpers/code-builder';
7-
import camelCase from 'camelcase';
7+
import camelCase from 'camelcase'; // eslint-disable-line import/no-extraneous-dependencies
88
import contentType from 'content-type';
99
import Oas from 'oas';
1010
import { matchesMimeType } from 'oas/utils';
1111
import { isReservedOrBuiltinsLC } from 'reserved2';
12-
import stringifyObject from 'stringify-object';
12+
import stringifyObject from 'stringify-object'; // eslint-disable-line import/no-extraneous-dependencies
1313

1414
/**
1515
* @note This regex also exists in `api/fetcher`.

packages/httpsnippet-client-api/tsup.config.ts

+10
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,15 @@ export default defineConfig((options: Options) => ({
1111
...config,
1212

1313
entry: ['src/index.ts'],
14+
15+
noExternal: [
16+
// These dependencies are ESM-only but because we're building for ESM **and** CJS we can't
17+
// treat them as external dependencies as CJS libraries can't load ESM code that uses `export`.
18+
// `noExternal` will instead treeshake these dependencies down and include them in our compiled
19+
// dists.
20+
'camelcase',
21+
'stringify-object',
22+
],
23+
1424
silent: !options.watch,
1525
}));

0 commit comments

Comments
 (0)