Skip to content

Commit

Permalink
* add _actualDependencies to package.json
Browse files Browse the repository at this point in the history
* use `build` instead of `dist`
* use `prepare` instead of `prepack`
* bundle dependencies in a vendor bundle
  • Loading branch information
tommy-mitchell committed Aug 14, 2023
1 parent ce2954b commit 5040a61
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules
dist
build
yarn.lock
55 changes: 36 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
"type": "module",
"exports": {
"types": "./index.d.ts",
"default": "./dist/index.js"
"default": "./build/index.js"
},
"sideEffects": false,
"engines": {
"node": ">=16.10"
},
"scripts": {
"prepack": "npm run build",
"prepare": "npm run build",
"build": "rollup -c",
"test": "xo && ava && tsd"
},
"files": [
"dist",
"build",
"index.d.ts"
],
"keywords": [
Expand All @@ -47,41 +47,58 @@
"cmd",
"console"
],
"dependencies": {
"@types/minimist": "^1.2.2",
"camelcase-keys": "^8.0.2",
"decamelize": "^6.0.0",
"decamelize-keys": "^2.0.1",
"hard-rejection": "^2.1.0",
"minimist-options": "4.1.0",
"normalize-package-data": "^5.0.0",
"read-pkg-up": "^9.1.0",
"redent": "^4.0.0",
"trim-newlines": "^5.0.0",
"type-fest": "^3.9.0",
"yargs-parser": "^21.1.1"
},
"_actualDependencies": [
"@types/minimist",
"camelcase-keys",
"decamelize",
"decamelize-keys",
"hard-rejection",
"minimist-options",
"normalize-package-data",
"read-pkg-up",
"redent",
"trim-newlines",
"type-fest",
"yargs-parser"
],
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.3",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.1.0",
"@rollup/plugin-terser": "^0.4.3",
"@types/minimist": "^1.2.2",
"ava": "^5.3.1",
"camelcase-keys": "^8.0.2",
"common-tags": "^1.8.2",
"decamelize": "^6.0.0",
"decamelize-keys": "^2.0.1",
"execa": "^7.2.0",
"hard-rejection": "^2.1.0",
"indent-string": "^5.0.0",
"minimist-options": "4.1.0",
"normalize-package-data": "^5.0.0",
"read-pkg": "^8.0.0",
"read-pkg-up": "^9.1.0",
"redent": "^4.0.0",
"rollup": "^3.27.0",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-filesize": "^10.0.0",
"rollup-plugin-license": "^3.0.1",
"rollup-plugin-multi-input": "^1.4.1",
"trim-newlines": "^5.0.0",
"tsd": "^0.28.1",
"xo": "^0.55.0"
"type-fest": "^3.9.0",
"xo": "^0.55.0",
"yargs-parser": "^21.1.1"
},
"xo": {
"rules": {
"unicorn/no-process-exit": "off",
"unicorn/error-message": "off"
}
},
"ignores": [
"build"
]
},
"ava": {
"files": [
Expand Down
37 changes: 22 additions & 15 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,42 @@ import json from '@rollup/plugin-json';
import commonjs from '@rollup/plugin-commonjs';
import {nodeResolve} from '@rollup/plugin-node-resolve';
import license from 'rollup-plugin-license';
import terser from '@rollup/plugin-terser';
import filesize from 'rollup-plugin-filesize';
import {defineConfig} from 'rollup';

const outDir = 'build';

export default defineConfig({
input: 'source/index.js',
input: [
'source/index.js',
'source/options.js',
'source/parser.js',
'source/utils.js',
'source/validate.js',
],
output: {
file: 'dist/index.js',
// https://rollupjs.org/configuration-options/#output-interop
dir: outDir,
interop: 'esModule',
// https://rollupjs.org/configuration-options/#output-generatedcode
generatedCode: {
preset: 'es2015',
},
chunkFileNames: '[name].js',
manualChunks(id) {
if (id.includes('node_modules')) {
return 'dependencies';
}
},
},
preserveEntrySignatures: 'allow-extension',
plugins: [
json(),
commonjs(),
nodeResolve(),
commonjs({
include: 'node_modules/**',
}),
json(),
license({
thirdParty: {
output: 'dist/dependencies.md',
},
}),
terser({
module: true,
toplevel: true,
format: {
comments: false,
output: `${outDir}/licenses.md`,
},
}),
filesize(),
Expand Down

0 comments on commit 5040a61

Please sign in to comment.