Skip to content

Commit

Permalink
fix: Tweak rollup config to use a more robust way of externalising no…
Browse files Browse the repository at this point in the history
…de_modules
  • Loading branch information
tristanmenzel committed Feb 13, 2024
1 parent e200db5 commit dfbd313
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@makerx/ts-toolkit",
"version": "4.0.0-beta.7",
"version": "4.0.0-beta.8",
"description": "This cli facilitates the creation of boilerplate files in a new typescript repo",
"type": "module",
"scripts": {
Expand Down Expand Up @@ -56,9 +56,10 @@
"npm-run-all": "^4.1.5",
"prettier": "3.2.5",
"rimraf": "5.0.5",
"rollup": "4.9.6",
"tsx": "^4.7.0",
"rollup": "4.10.0",
"tsx": "4.7.1",
"typescript": "5.3.3",
"vitest": "1.2.2"
"vitest": "1.2.2",
"@rollup/plugin-commonjs": "25.0.7"
}
}
6 changes: 4 additions & 2 deletions rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import nodeResolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import typescript from '@rollup/plugin-typescript'
import json from '@rollup/plugin-json'
import type { RollupOptions } from 'rollup'
import pkg from './package.json' with { type: 'json' }

const config: RollupOptions = {
input: ['src/index.ts', 'src/bin/run-cli.ts'],
output: [
Expand All @@ -28,11 +29,12 @@ const config: RollupOptions = {
propertyReadSideEffects: false,
},
// List modules that should not be included in the output bundle (ie. they should remain external dependencies)
external: [...Object.keys(pkg.dependencies) /*, ...Object.keys(pkg.peerDependencies) */],
external: [/node_modules/],
plugins: [
typescript({
tsconfig: 'tsconfig.build.json',
}),
commonjs(),
nodeResolve(),
json(),
],
Expand Down
5 changes: 2 additions & 3 deletions src/templates/node/rollup.config.ts.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import commonjs from '@rollup/plugin-commonjs'
import typescript from '@rollup/plugin-typescript'
import json from '@rollup/plugin-json'
import type { RollupOptions } from 'rollup'
import pkg from './package.json' with { type: 'json' }
const typedPackage = pkg as {dependencies?: Record<string, string>, peerDependencies?: Record<string, string>}

const config: RollupOptions = {
input: ['src/index.ts'],
output: [
Expand All @@ -30,7 +29,7 @@ const config: RollupOptions = {
propertyReadSideEffects: false,
},
// List modules that should not be included in the output bundle (ie. they should remain external dependencies)
external: [...Object.keys(typedPackage.dependencies ?? {}) , ...Object.keys(typedPackage.peerDependencies?? {}) ],
external: [/node_modules/],
plugins: [
typescript({
tsconfig: 'tsconfig.build.json',
Expand Down

0 comments on commit dfbd313

Please sign in to comment.