pkgbld 1.5.4 → 1.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  import { InternalModuleFormat, Plugin } from 'rollup';
2
2
  import { getCliOptions } from './get-cli-options';
3
- export declare function getBuildPlugins(format: InternalModuleFormat, config: ReturnType<typeof getCliOptions>): Plugin[];
3
+ export declare function getBuildPlugins(format: InternalModuleFormat, config: ReturnType<typeof getCliOptions>, inputs?: string[], currentInput?: string): Plugin[];
4
4
  export declare function getOutputPlugins(format: InternalModuleFormat, config: ReturnType<typeof getCliOptions>): Plugin[];
package/dist/helpers.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { getCliOptions } from './get-cli-options';
2
2
  export declare function getHelpers(pkg: any): {
3
- external: (id: string | string[]) => any;
4
3
  getGlobalName: (anInput: string) => string;
5
4
  getExternalGlobalName: (id: string) => string;
6
5
  umdFilter: typeof umdFilter;
package/dist/index.js CHANGED
@@ -11,8 +11,8 @@ var commonjs = require('@rollup/plugin-commonjs');
11
11
  var resolve = require('@rollup/plugin-node-resolve');
12
12
  var preprocess = require('rollup-plugin-preprocess');
13
13
  var rollupPluginTerser = require('rollup-plugin-terser');
14
- var clean = require('@rollup-extras/plugin-clean');
15
- var isBuiltinModule = require('is-builtin-module');
14
+ var cleanFactory = require('@rollup-extras/plugin-clean');
15
+ var externals = require('@rollup-extras/plugin-externals');
16
16
  var camelCase = require('lodash/camelCase');
17
17
 
18
18
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -24,8 +24,8 @@ var typescript__default = /*#__PURE__*/_interopDefaultLegacy(typescript);
24
24
  var commonjs__default = /*#__PURE__*/_interopDefaultLegacy(commonjs);
25
25
  var resolve__default = /*#__PURE__*/_interopDefaultLegacy(resolve);
26
26
  var preprocess__default = /*#__PURE__*/_interopDefaultLegacy(preprocess);
27
- var clean__default = /*#__PURE__*/_interopDefaultLegacy(clean);
28
- var isBuiltinModule__default = /*#__PURE__*/_interopDefaultLegacy(isBuiltinModule);
27
+ var cleanFactory__default = /*#__PURE__*/_interopDefaultLegacy(cleanFactory);
28
+ var externals__default = /*#__PURE__*/_interopDefaultLegacy(externals);
29
29
  var camelCase__default = /*#__PURE__*/_interopDefaultLegacy(camelCase);
30
30
 
31
31
  async function createSubpackages(inputs, config) {
@@ -74,46 +74,8 @@ async function getPackage() {
74
74
  return [pkgPath, JSON.parse(buffer.toString())];
75
75
  }
76
76
 
77
- function getBuildPlugins(format, config) {
78
- const result = [
79
- clean__default["default"](),
80
- resolve__default["default"](),
81
- commonjs__default["default"](),
82
- typescript__default["default"]()
83
- ];
84
- if (config.preprocess.length) {
85
- result.unshift(preprocess__default["default"]({ include: config.preprocess.map(name => `src/${name}.ts`), context: getPreprocessContext(format) }));
86
- }
87
- return result;
88
- }
89
- function getPreprocessContext(format) {
90
- if (format == 'es') {
91
- return { esm: true };
92
- }
93
- else {
94
- return { cjs: true };
95
- }
96
- }
97
- function getOutputPlugins(format, config) {
98
- return config.compressTargets.includes(format) ? [rollupPluginTerser.terser({
99
- mangle: {
100
- properties: {
101
- regex: /_$/
102
- }
103
- }
104
- })] : [];
105
- }
106
-
107
77
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
108
78
  function getHelpers(pkg) {
109
- const scopeTest = /(@.+)\/.+$/g.exec(pkg.name);
110
- let scope = undefined;
111
- if (scopeTest && scopeTest[1]) {
112
- scope = scopeTest[1];
113
- }
114
- const external = scope != null
115
- ? (id) => id.indexOf('node_modules') >= 0 || id.indexOf(scope) >= 0 || isBuiltinModule__default["default"](id)
116
- : (id) => id.indexOf('node_modules') >= 0 || isBuiltinModule__default["default"](id);
117
79
  function getGlobalName(anInput) {
118
80
  return camelCase__default["default"](path__default["default"].join(pkg.name, path__default["default"].basename(anInput, '.ts') !== 'index' ? path__default["default"].basename(anInput, '.ts') : ''));
119
81
  }
@@ -124,7 +86,6 @@ function getHelpers(pkg) {
124
86
  return camelCase__default["default"](id);
125
87
  }
126
88
  return {
127
- external,
128
89
  getGlobalName,
129
90
  getExternalGlobalName,
130
91
  umdFilter
@@ -165,6 +126,41 @@ function getTimeDiff(starting) {
165
126
  return `${now - starting}ms`;
166
127
  }
167
128
 
129
+ const clean = cleanFactory__default["default"]();
130
+ function getBuildPlugins(format, config, inputs, currentInput) {
131
+ const result = [
132
+ clean,
133
+ externals__default["default"]({
134
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
135
+ external: (id, external) => external || (format === 'umd' ? isExternalInput(id, inputs, currentInput) : false)
136
+ }),
137
+ resolve__default["default"](),
138
+ commonjs__default["default"](),
139
+ typescript__default["default"]()
140
+ ];
141
+ if (config.preprocess.length) {
142
+ result.unshift(preprocess__default["default"]({ include: config.preprocess.map(name => `src/${name}.ts`), context: getPreprocessContext(format) }));
143
+ }
144
+ return result;
145
+ }
146
+ function getPreprocessContext(format) {
147
+ if (format == 'es') {
148
+ return { esm: true };
149
+ }
150
+ else {
151
+ return { cjs: true };
152
+ }
153
+ }
154
+ function getOutputPlugins(format, config) {
155
+ return config.compressTargets.includes(format) ? [rollupPluginTerser.terser({
156
+ mangle: {
157
+ properties: {
158
+ regex: /_$/
159
+ }
160
+ }
161
+ })] : [];
162
+ }
163
+
168
164
  function getRollupConfigs(inputs, config, helpers) {
169
165
  const configs = [];
170
166
  if (config.formats.includes('es')) {
@@ -178,8 +174,7 @@ function getRollupConfigs(inputs, config, helpers) {
178
174
  plugins: getOutputPlugins('es', config),
179
175
  sourcemap: config.sourcemapTargets.includes('es')
180
176
  },
181
- plugins: getBuildPlugins('es', config),
182
- external: helpers.external
177
+ plugins: getBuildPlugins('es', config)
183
178
  });
184
179
  }
185
180
  if (config.formats.includes('cjs')) {
@@ -194,8 +189,7 @@ function getRollupConfigs(inputs, config, helpers) {
194
189
  plugins: getOutputPlugins('cjs', config),
195
190
  sourcemap: config.sourcemapTargets.includes('cjs')
196
191
  },
197
- plugins: getBuildPlugins('cjs', config),
198
- external: helpers.external
192
+ plugins: getBuildPlugins('cjs', config)
199
193
  });
200
194
  }
201
195
  const umdConfigs = inputs.filter((input) => umdFilter(config, input)).map(currentInput => ({
@@ -209,8 +203,7 @@ function getRollupConfigs(inputs, config, helpers) {
209
203
  plugins: getOutputPlugins('umd', config),
210
204
  sourcemap: config.sourcemapTargets.includes('umd')
211
205
  },
212
- plugins: getBuildPlugins('umd', config),
213
- external: (id) => helpers.external(id) || isExternalInput(id, inputs, currentInput)
206
+ plugins: getBuildPlugins('umd', config, inputs, currentInput)
214
207
  }));
215
208
  if (umdConfigs && umdConfigs.length) {
216
209
  configs.push(...umdConfigs);
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.5.4",
2
+ "version": "1.5.5",
3
3
  "license": "MIT",
4
4
  "name": "pkgbld",
5
5
  "author": {
@@ -47,7 +47,6 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@niceties/logger": "1.1.4",
50
- "is-builtin-module": "3.2.0",
51
50
  "lodash": "4.17.21",
52
51
  "rollup": "2.79.0",
53
52
  "rollup-plugin-terser": "7.0.2",
@@ -56,6 +55,7 @@
56
55
  "@rollup/plugin-commonjs": "22.0.2",
57
56
  "@rollup/plugin-node-resolve": "14.1.0",
58
57
  "@rollup-extras/plugin-clean": "1.2.4",
58
+ "@rollup-extras/plugin-externals": "1.0.2",
59
59
  "typescript": "4.8.3",
60
60
  "minimist": "1.2.6"
61
61
  }