Skip to content

Commit

Permalink
fix(httpsnippet-client-api): making external deps no longer external
Browse files Browse the repository at this point in the history
  • Loading branch information
erunion committed Nov 2, 2023
1 parent 0dfd14c commit 1ec030a
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 11 deletions.
11 changes: 8 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
"oas": "^24.0.0",
"remove-undefined-objects": "^5.0.0"
},
"bundledDependencies": [
"get-stream"
],
"devDependencies": {
"@api/test-utils": "file:../test-utils",
"@readme/oas-examples": "^5.12.0",
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/lib/prepareParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import stream from 'node:stream';
import caseless from 'caseless';
import DatauriParser from 'datauri/parser.js';
import datauri from 'datauri/sync.js';
// `get-stream` is included in our bundle, see `tsup.config.ts`
// eslint-disable-next-line import/no-extraneous-dependencies
import { getStreamAsBuffer } from 'get-stream';
import lodashMerge from 'lodash.merge';
import removeUndefinedObjects from 'remove-undefined-objects';
Expand Down
9 changes: 6 additions & 3 deletions packages/core/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ export default defineConfig((options: Options) => ({
...config,

entry: ['src/errors/fetchError.ts', 'src/lib/index.ts', 'src/index.ts', 'src/types.ts'],

noExternal: [
// `get-stream` is ESM-only and we need to build for CommonJS,
// so including it here means that its (tree-shaken!) source code
// will be included directly in our dist outputs.
// These dependencies are ESM-only but because we're building for ESM **and** CJS we can't
// treat them as external dependencies as CJS libraries can't load ESM code that uses `export`.
// `noExternal` will instead treeshake these dependencies down and include them in our compiled
// dists.
'get-stream',
],

silent: !options.watch,
}));
10 changes: 7 additions & 3 deletions packages/httpsnippet-client-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,25 @@
"node": ">=18"
},
"dependencies": {
"camelcase": "^8.0.0",
"content-type": "^1.0.5",
"reserved2": "^0.1.5",
"stringify-object": "^5.0.0"
"reserved2": "^0.1.5"
},
"peerDependencies": {
"@readme/httpsnippet": ">=8.1.2",
"oas": "^24.0.0"
},
"bundledDependencies": [
"camelcase",
"stringify-object"
],
"devDependencies": {
"@readme/oas-examples": "^5.12.0",
"@readme/openapi-parser": "^2.5.0",
"@types/content-type": "^1.1.6",
"@types/stringify-object": "^4.0.3",
"@vitest/coverage-v8": "^0.34.4",
"camelcase": "^8.0.0",
"stringify-object": "^5.0.0",
"typescript": "^5.2.2",
"vitest": "^0.34.5"
},
Expand Down
10 changes: 10 additions & 0 deletions packages/httpsnippet-client-api/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,15 @@ export default defineConfig((options: Options) => ({
...config,

entry: ['src/index.ts'],

noExternal: [
// These dependencies are ESM-only but because we're building for ESM **and** CJS we can't
// treat them as external dependencies as CJS libraries can't load ESM code that uses `export`.
// `noExternal` will instead treeshake these dependencies down and include them in our compiled
// dists.
'camelcase',
'stringify-object',
],

silent: !options.watch,
}));

0 comments on commit 1ec030a

Please sign in to comment.