Skip to content

Commit 3a65ad9

Browse files
committed
Added option autoExclude and improved documentation
Signed-off-by: Jaid <[email protected]>
1 parent dbad0ef commit 3a65ad9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ const pkgHook = "publishimoGeneratedPkg"
2828
* @property {boolean} [productionOnly=true] If true, only applies changes and emits files in Webpack mode `production`.
2929
* @property {string} [debugFolder=null] Directory where debug info files get written to.
3030
* @property {boolean} [json5=false] If true, package output will be written with `json5.stringify` instead of `JSON.stringify`.
31+
* @property {boolean} [autoExclude=false] If `true`, unneeded fields will be guessed and automatically excluded from output package.
32+
* @property {string[]} [includeFields=[]] Field names that should forcefully be forwarded from `options.pkg` to generated pkg. For example, use `includeFields: ["babel"]` to include your Babel config in your output package.
33+
* @property {string[]} [excludeFields=[]] Fields names that are never written to generated pkg.
3134
*/
3235

3336
/**
@@ -50,7 +53,10 @@ export default class {
5053
unicodeCopyright: true,
5154
productionOnly: true,
5255
debugFolder: null,
56+
incudeFields: [],
57+
excludeFields: [],
5358
json5: false,
59+
autoExclude: false,
5460
...options,
5561
}
5662
if (this.options.format === true) {
@@ -94,8 +100,9 @@ export default class {
94100
if (this.options.autoTypes) {
95101
publishimoConfig.types = mainPath
96102
}
97-
if (compilation.options.target !== "node") { // Don't include dependencies in package.json if export target is not a Node module
103+
if (this.options.autoExclude && compilation.options.target !== "node") { // Don't include dependencies in package.json if export target is not a Node module
98104
publishimoConfig.excludeFields = [
105+
...publishimoConfig.excludeFields,
99106
"dependencies",
100107
"peerDependencies",
101108
"optionalDependencies",

0 commit comments

Comments
 (0)