@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 +6 -3
- package/esm/plugin-helper.d.ts +3 -8
- package/esm/plugin-helper.d.ts.map +1 -1
- package/esm/plugin-helper.js +2 -20
- package/esm/plugin-helper.js.map +1 -1
- package/package.json +1 -1
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
|
|
41
|
-
|
|
40
|
+
merge(config, {
|
|
41
|
+
define: {
|
|
42
|
+
__MY_VAR__: JSON.stringify("value"),
|
|
43
|
+
},
|
|
44
|
+
});
|
|
42
45
|
}),
|
|
43
46
|
};
|
|
44
47
|
},
|
package/esm/plugin-helper.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type EvBundlerCtx, merge } from "@evjs/ev";
|
|
2
2
|
import type { ConfigComplete } from "@utoo/pack";
|
|
3
|
-
type
|
|
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
|
|
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,
|
|
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"}
|
package/esm/plugin-helper.js
CHANGED
|
@@ -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
|
|
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
|
package/esm/plugin-helper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-helper.js","sourceRoot":"","sources":["../src/plugin-helper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin-helper.js","sourceRoot":"","sources":["../src/plugin-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,EAAE,MAAM,UAAU,CAAC;AAKpD;;;;;;;;;;;;;;;;;;;;;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,EAAE,CAAC;YAC5C,EAAE,CACA,MAAmC,EACnC,GAA8C,CAC/C,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AACD,OAAO,EAAE,KAAK,EAAE,CAAC"}
|