@evjs/bundler-utoopack 0.1.2 → 0.1.3

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/README.md CHANGED
@@ -27,7 +27,7 @@ The `utoopack()` helper wraps your plugin hooks for type-safe configuration muta
27
27
 
28
28
  ```ts
29
29
  import { defineConfig } from "@evjs/ev";
30
- import { utoopack } from "@evjs/bundler-utoopack";
30
+ import { merge, utoopack } from "@evjs/bundler-utoopack";
31
31
 
32
32
  export default defineConfig({
33
33
  plugins: [
@@ -37,8 +37,11 @@ export default defineConfig({
37
37
  return {
38
38
  bundlerConfig: utoopack((config) => {
39
39
  // config is typed as ConfigComplete from @utoo/pack
40
- config.env ??= {};
41
- config.env.__MY_VAR__ = JSON.stringify("value");
40
+ merge(config, {
41
+ define: {
42
+ __MY_VAR__: JSON.stringify("value"),
43
+ },
44
+ });
42
45
  }),
43
46
  };
44
47
  },
@@ -1,10 +1,6 @@
1
- import type { EvBundlerCtx } from "@evjs/ev";
1
+ import { type EvBundlerCtx, merge } from "@evjs/ev";
2
2
  import type { ConfigComplete } from "@utoo/pack";
3
- type Primitive = string | number | boolean | bigint | symbol | null | undefined;
4
- type Builtin = Primitive | RegExp | ((...args: never[]) => unknown);
5
- export type ConfigPatch<T> = T extends Builtin ? T : T extends readonly unknown[] ? T : T extends object ? {
6
- [K in keyof T]?: ConfigPatch<T[K]>;
7
- } : T;
3
+ export type { ConfigPatch } from "@evjs/ev";
8
4
  /**
9
5
  * Typed wrapper for utoopack configuration in plugin bundler hooks.
10
6
  *
@@ -28,6 +24,5 @@ export type ConfigPatch<T> = T extends Builtin ? T : T extends readonly unknown[
28
24
  * ```
29
25
  */
30
26
  export declare function utoopack<T = unknown>(fn: (config: ConfigComplete, ctx: EvBundlerCtx<ConfigComplete>) => void): (config: T, ctx: EvBundlerCtx<T>) => void;
31
- export declare function merge(config: ConfigComplete, patch: ConfigPatch<ConfigComplete>): void;
32
- export {};
27
+ export { merge };
33
28
  //# sourceMappingURL=plugin-helper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-helper.d.ts","sourceRoot":"","sources":["../src/plugin-helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAChF,KAAK,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC,CAAC;AAEpE,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAC1C,CAAC,GACD,CAAC,SAAS,SAAS,OAAO,EAAE,GAC1B,CAAC,GACD,CAAC,SAAS,MAAM,GACd;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACtC,CAAC,CAAC;AAEV;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,GAAG,OAAO,EAClC,EAAE,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,YAAY,CAAC,cAAc,CAAC,KAAK,IAAI,GACtE,CAAC,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,CAS3C;AAED,wBAAgB,KAAK,CACnB,MAAM,EAAE,cAAc,EACtB,KAAK,EAAE,WAAW,CAAC,cAAc,CAAC,GACjC,IAAI,CAKN"}
1
+ {"version":3,"file":"plugin-helper.d.ts","sourceRoot":"","sources":["../src/plugin-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,GAAG,OAAO,EAClC,EAAE,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,YAAY,CAAC,cAAc,CAAC,KAAK,IAAI,GACtE,CAAC,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,CAS3C;AACD,OAAO,EAAE,KAAK,EAAE,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { merge } from "@evjs/ev";
1
2
  /**
2
3
  * Typed wrapper for utoopack configuration in plugin bundler hooks.
3
4
  *
@@ -27,24 +28,5 @@ export function utoopack(fn) {
27
28
  }
28
29
  };
29
30
  }
30
- export function merge(config, patch) {
31
- mergeObject(config, patch);
32
- }
33
- function mergeObject(target, patch) {
34
- for (const [key, value] of Object.entries(patch)) {
35
- const current = target[key];
36
- if (isPlainObject(current) && isPlainObject(value)) {
37
- mergeObject(current, value);
38
- continue;
39
- }
40
- target[key] = value;
41
- }
42
- }
43
- function isPlainObject(value) {
44
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
45
- return false;
46
- }
47
- const prototype = Object.getPrototypeOf(value);
48
- return prototype === Object.prototype || prototype === null;
49
- }
31
+ export { merge };
50
32
  //# sourceMappingURL=plugin-helper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-helper.js","sourceRoot":"","sources":["../src/plugin-helper.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,QAAQ,CACtB,EAAuE;IAEvE,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;QACrB,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,KAAK,UAAU,EA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AAG,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,KAAK,UAAU,EAAE,CAAC;YAC5C,EAAE,CACA,MAAmC,EACnC,GAA8C,CAC/C,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AACD,OAAO,EAAE,KAAK,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evjs/bundler-utoopack",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Utoopack bundler adapter for the evjs framework",
5
5
  "type": "module",
6
6
  "publishConfig": {