pkgbld 1.15.1 → 1.15.2

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.
package/dist/eject.d.ts CHANGED
@@ -2,5 +2,5 @@ import type { PackageJson, PkgbldRollupPlugin, Provider } from './types';
2
2
  import type { RollupOptions } from 'rollup';
3
3
  import { getCliOptions } from './get-cli-options';
4
4
  import { getHelpers } from './helpers';
5
- export declare function createEjectProvider(preimporMap: Map<string, Promise<never>>): Promise<[Provider, PkgbldRollupPlugin[]]>;
5
+ export declare function createEjectProvider(preimportMap: Map<string, Promise<never>>): Promise<[Provider, PkgbldRollupPlugin[]]>;
6
6
  export declare function ejectConfig(config: RollupOptions[], pkgPath: string, options: ReturnType<typeof getCliOptions>, inputs: string[], helpers: ReturnType<typeof getHelpers>, pkg: PackageJson): Promise<void>;
@@ -1,4 +1,4 @@
1
1
  import type { PkgbldRollupPlugin, Provider } from './types';
2
2
  import externals from './builtin-plugins/externals';
3
3
  export declare const plugins: (typeof externals)[];
4
- export declare function createProvider(preimporMap: Map<string, Promise<never>>): [Provider, PkgbldRollupPlugin[]];
4
+ export declare function createProvider(preimportMap: Map<string, Promise<never>>): [Provider, PkgbldRollupPlugin[]];
package/dist/index.js CHANGED
@@ -106,14 +106,16 @@ async function externals (provider, config, inputs) {
106
106
  provider.provide(() => pluginExternals(), 2000 /* Priotiry.externals */, { format });
107
107
  }
108
108
  if (!allowGenericUmd && config.umdInputs.length > 0) {
109
+ const curry = (await provider.import('lodash/curry.js'));
109
110
  for (const currentInput of config.umdInputs) {
111
+ const isExternal = curry((currentInput, id, external) => external || isExternalInput(currentInput, inputs, id, config))(currentInput);
110
112
  provider.provide(() => pluginExternals({
111
- external: (id, external) => external || isExternalInput(currentInput, inputs, id, config)
113
+ external: isExternal
112
114
  }), 2000 /* Priotiry.externals */, { format: 'umd', inputs: [`./${config.sourceDir}/${currentInput}.ts`] });
113
115
  }
114
116
  // for eject config
115
117
  provider.globalImport('path', 'path');
116
- provider.globalSetupt(isExternalInput);
118
+ provider.globalSetup(isExternalInput);
117
119
  }
118
120
  }
119
121
  function isExternalInput(currentInput, inputs, id, config) {
@@ -207,18 +209,18 @@ const plugins = [
207
209
  binify
208
210
  ];
209
211
  const noop = () => undefined;
210
- function createProvider(preimporMap) {
212
+ function createProvider(preimportMap) {
211
213
  const plugins = [];
212
214
  return [{
213
215
  provide: (plugin, priority, options) => {
214
216
  plugins.push({ priority, plugin, format: options?.format, inputs: options?.inputs, outputPlugin: options?.outputPlugin });
215
217
  },
216
218
  import: async (name, exportName) => {
217
- const result = preimporMap.has(name) ? await preimporMap.get(name) : await import(name);
219
+ const result = preimportMap.has(name) ? await preimportMap.get(name) : await import(name);
218
220
  return result[exportName ?? 'default'];
219
221
  },
220
222
  globalImport: noop,
221
- globalSetupt: noop
223
+ globalSetup: noop
222
224
  }, plugins];
223
225
  }
224
226
 
@@ -532,7 +534,7 @@ async function writeJson(path, json) {
532
534
  const imports = new Map;
533
535
  const setup = new Set;
534
536
  let generate, generateGlobals;
535
- async function createEjectProvider(preimporMap) {
537
+ async function createEjectProvider(preimportMap) {
536
538
  const createMockProvider = (await import('@slimlib/smart-mock')).default;
537
539
  const provider = createMockProvider();
538
540
  const createMock = provider.createMock;
@@ -544,7 +546,7 @@ async function createEjectProvider(preimporMap) {
544
546
  plugins.push({ priority, plugin, format: options?.format, inputs: options?.inputs, outputPlugin: options?.outputPlugin });
545
547
  },
546
548
  import: async (name, exportName) => {
547
- const result = preimporMap.has(name) ? await preimporMap.get(name) : await import(name);
549
+ const result = preimportMap.has(name) ? await preimportMap.get(name) : await import(name);
548
550
  const exports = result[exportName ?? 'default'];
549
551
  const mangledName = lodash.camelCase(name);
550
552
  imports.set(name, mangledName);
@@ -554,7 +556,7 @@ async function createEjectProvider(preimporMap) {
554
556
  imports.set(module, exportName ?? 'default');
555
557
  },
556
558
  // eslint-disable-next-line @typescript-eslint/ban-types
557
- globalSetupt: (code) => {
559
+ globalSetup: (code) => {
558
560
  if (typeof code === 'function') {
559
561
  setup.add(code.toString());
560
562
  }
@@ -583,6 +585,7 @@ async function ejectConfig(config, pkgPath, options, inputs, helpers, pkg) {
583
585
  .join('\n');
584
586
  const setupString = Array.from(setup)
585
587
  .join('\n');
588
+ console.log(setupString);
586
589
  const { minify } = await import('terser');
587
590
  const result = await minify(`${importsString}\n${setupString}\nexport default ${text};`, {
588
591
  module: true,
@@ -655,8 +658,8 @@ async function execute() {
655
658
  checkTsConfig(options, mainLogger);
656
659
  const inputs = processPackage(pkg, options);
657
660
  const helpers = getHelpers(pkg.name);
658
- const preimporMap = preimport();
659
- const provider = options.eject ? await createEjectProvider(preimporMap) : createProvider(preimporMap);
661
+ const preimportMap = preimport();
662
+ const provider = options.eject ? await createEjectProvider(preimportMap) : createProvider(preimportMap);
660
663
  const rollupConfigs = await getRollupConfigs(provider, inputs, options, helpers);
661
664
  if (options.eject) {
662
665
  await ejectConfig(rollupConfigs, pkgPath, options, inputs, helpers, pkg);
package/dist/types.d.ts CHANGED
@@ -32,7 +32,7 @@ export type Provider = {
32
32
  provide: ProvideFunction;
33
33
  import: (module: string, exportName?: string) => Promise<((...args: unknown[]) => Plugin)>;
34
34
  globalImport: (module: string, exportName?: string | string[]) => void;
35
- globalSetupt: (code: Function | string) => void;
35
+ globalSetup: (code: Function | string) => void;
36
36
  };
37
37
  export type PkgbldRollupPlugin = {
38
38
  plugin: () => Plugin;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.15.1",
2
+ "version": "1.15.2",
3
3
  "license": "MIT",
4
4
  "name": "pkgbld",
5
5
  "author": {