@utoo/pack-shared 1.1.11-rc.0 → 1.1.12

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,6 +1,88 @@
1
- import type webpack from "webpack";
2
1
  import { BundleOptions } from "./config";
3
- export type WebpackConfig = Partial<Pick<webpack.Configuration, "name" | "entry" | "mode" | "module" | "resolve" | "externals" | "output" | "target" | "devtool" | "optimization" | "plugins" | "stats">> & {
2
+ export interface WebpackPluginInstance {
3
+ apply: (compiler: any) => void;
4
+ [key: string]: any;
5
+ }
6
+ export interface WebpackRuleSetRule {
7
+ test?: RegExp | string;
8
+ use?: any;
9
+ loader?: string;
10
+ options?: any;
11
+ oneOf?: WebpackRuleSetRule[];
12
+ type?: string;
13
+ generator?: any;
14
+ parser?: any;
15
+ sideEffects?: boolean;
16
+ exclude?: any;
17
+ include?: any;
18
+ resourceQuery?: any;
19
+ issuer?: any;
20
+ }
21
+ export interface WebpackModule {
22
+ rules?: (WebpackRuleSetRule | "...")[] | WebpackRuleSetRule[];
23
+ }
24
+ export interface WebpackResolve {
25
+ alias?: Record<string, string | false | string[]> | Array<{
26
+ name: string;
27
+ alias: string | false | string[];
28
+ }>;
29
+ extensions?: string[];
30
+ modules?: string[];
31
+ mainFields?: string[];
32
+ conditionNames?: string[];
33
+ fallback?: Record<string, string | false | string[]>;
34
+ plugins?: any[];
35
+ }
36
+ export interface WebpackOutput {
37
+ path?: string;
38
+ publicPath?: string | ((...args: any[]) => string);
39
+ filename?: string | ((...args: any[]) => string);
40
+ chunkFilename?: string | ((...args: any[]) => string);
41
+ assetModuleFilename?: string;
42
+ library?: any;
43
+ libraryTarget?: string;
44
+ globalObject?: string;
45
+ clean?: boolean | {
46
+ keep?: any;
47
+ };
48
+ }
49
+ export interface WebpackOptimization {
50
+ minimize?: boolean;
51
+ minimizer?: any[];
52
+ splitChunks?: any;
53
+ runtimeChunk?: any;
54
+ moduleIds?: string;
55
+ chunkIds?: string;
56
+ concatenateModules?: boolean;
57
+ }
58
+ export type WebpackEntry = string | string[] | Record<string, string | {
59
+ import: string;
60
+ library?: {
61
+ type: string;
62
+ name?: string | string[];
63
+ export?: string | string[];
64
+ };
65
+ } | string[]>;
66
+ export type WebpackExternals = string | RegExp | Record<string, string | string[] | object> | (string | RegExp | Record<string, string | string[] | object>)[];
67
+ export type WebpackTarget = string | string[];
68
+ export type WebpackDevTool = string | boolean;
69
+ export type WebpackStats = string | boolean | object;
70
+ export type WebpackPlugins = (WebpackPluginInstance | any)[];
71
+ export type WebpackMode = "development" | "production" | "none";
72
+ export interface WebpackConfig {
73
+ name?: string;
74
+ entry?: WebpackEntry;
75
+ mode?: WebpackMode;
76
+ module?: WebpackModule;
77
+ resolve?: WebpackResolve;
78
+ externals?: WebpackExternals;
79
+ output?: WebpackOutput;
80
+ target?: WebpackTarget;
81
+ devtool?: WebpackDevTool;
82
+ optimization?: WebpackOptimization;
83
+ plugins?: WebpackPlugins;
84
+ stats?: WebpackStats;
4
85
  webpackMode: true;
5
- };
86
+ devServer?: any;
87
+ }
6
88
  export declare function compatOptionsFromWebpack(webpackConfig: WebpackConfig): BundleOptions;
@@ -30,6 +30,9 @@ function compatMode(webpackMode) {
30
30
  : "production";
31
31
  }
32
32
  function compatEntry(webpackEntry) {
33
+ if (!webpackEntry) {
34
+ return undefined;
35
+ }
33
36
  const entry = [];
34
37
  switch (typeof webpackEntry) {
35
38
  case "string":
@@ -248,16 +251,17 @@ function compatExternals(webpackExternals) {
248
251
  }
249
252
  else if (typeof value === "object" && value !== null) {
250
253
  // Object format: handle complex configurations
251
- if ("root" in value || "commonjs" in value || "amd" in value) {
254
+ const val = value;
255
+ if ("root" in val || "commonjs" in val || "amd" in val) {
252
256
  // Standard webpack externals object format
253
- if (value.commonjs) {
254
- externals[key] = `commonjs ${value.commonjs}`;
257
+ if (val.commonjs) {
258
+ externals[key] = `commonjs ${val.commonjs}`;
255
259
  }
256
- else if (value.root) {
257
- externals[key] = value.root;
260
+ else if (val.root) {
261
+ externals[key] = val.root;
258
262
  }
259
- else if (value.amd) {
260
- externals[key] = value.amd;
263
+ else if (val.amd) {
264
+ externals[key] = val.amd;
261
265
  }
262
266
  else {
263
267
  externals[key] = key;
@@ -1,6 +1,88 @@
1
- import type webpack from "webpack";
2
1
  import { BundleOptions } from "./config";
3
- export type WebpackConfig = Partial<Pick<webpack.Configuration, "name" | "entry" | "mode" | "module" | "resolve" | "externals" | "output" | "target" | "devtool" | "optimization" | "plugins" | "stats">> & {
2
+ export interface WebpackPluginInstance {
3
+ apply: (compiler: any) => void;
4
+ [key: string]: any;
5
+ }
6
+ export interface WebpackRuleSetRule {
7
+ test?: RegExp | string;
8
+ use?: any;
9
+ loader?: string;
10
+ options?: any;
11
+ oneOf?: WebpackRuleSetRule[];
12
+ type?: string;
13
+ generator?: any;
14
+ parser?: any;
15
+ sideEffects?: boolean;
16
+ exclude?: any;
17
+ include?: any;
18
+ resourceQuery?: any;
19
+ issuer?: any;
20
+ }
21
+ export interface WebpackModule {
22
+ rules?: (WebpackRuleSetRule | "...")[] | WebpackRuleSetRule[];
23
+ }
24
+ export interface WebpackResolve {
25
+ alias?: Record<string, string | false | string[]> | Array<{
26
+ name: string;
27
+ alias: string | false | string[];
28
+ }>;
29
+ extensions?: string[];
30
+ modules?: string[];
31
+ mainFields?: string[];
32
+ conditionNames?: string[];
33
+ fallback?: Record<string, string | false | string[]>;
34
+ plugins?: any[];
35
+ }
36
+ export interface WebpackOutput {
37
+ path?: string;
38
+ publicPath?: string | ((...args: any[]) => string);
39
+ filename?: string | ((...args: any[]) => string);
40
+ chunkFilename?: string | ((...args: any[]) => string);
41
+ assetModuleFilename?: string;
42
+ library?: any;
43
+ libraryTarget?: string;
44
+ globalObject?: string;
45
+ clean?: boolean | {
46
+ keep?: any;
47
+ };
48
+ }
49
+ export interface WebpackOptimization {
50
+ minimize?: boolean;
51
+ minimizer?: any[];
52
+ splitChunks?: any;
53
+ runtimeChunk?: any;
54
+ moduleIds?: string;
55
+ chunkIds?: string;
56
+ concatenateModules?: boolean;
57
+ }
58
+ export type WebpackEntry = string | string[] | Record<string, string | {
59
+ import: string;
60
+ library?: {
61
+ type: string;
62
+ name?: string | string[];
63
+ export?: string | string[];
64
+ };
65
+ } | string[]>;
66
+ export type WebpackExternals = string | RegExp | Record<string, string | string[] | object> | (string | RegExp | Record<string, string | string[] | object>)[];
67
+ export type WebpackTarget = string | string[];
68
+ export type WebpackDevTool = string | boolean;
69
+ export type WebpackStats = string | boolean | object;
70
+ export type WebpackPlugins = (WebpackPluginInstance | any)[];
71
+ export type WebpackMode = "development" | "production" | "none";
72
+ export interface WebpackConfig {
73
+ name?: string;
74
+ entry?: WebpackEntry;
75
+ mode?: WebpackMode;
76
+ module?: WebpackModule;
77
+ resolve?: WebpackResolve;
78
+ externals?: WebpackExternals;
79
+ output?: WebpackOutput;
80
+ target?: WebpackTarget;
81
+ devtool?: WebpackDevTool;
82
+ optimization?: WebpackOptimization;
83
+ plugins?: WebpackPlugins;
84
+ stats?: WebpackStats;
4
85
  webpackMode: true;
5
- };
86
+ devServer?: any;
87
+ }
6
88
  export declare function compatOptionsFromWebpack(webpackConfig: WebpackConfig): BundleOptions;
@@ -27,6 +27,9 @@ function compatMode(webpackMode) {
27
27
  : "production";
28
28
  }
29
29
  function compatEntry(webpackEntry) {
30
+ if (!webpackEntry) {
31
+ return undefined;
32
+ }
30
33
  const entry = [];
31
34
  switch (typeof webpackEntry) {
32
35
  case "string":
@@ -245,16 +248,17 @@ function compatExternals(webpackExternals) {
245
248
  }
246
249
  else if (typeof value === "object" && value !== null) {
247
250
  // Object format: handle complex configurations
248
- if ("root" in value || "commonjs" in value || "amd" in value) {
251
+ const val = value;
252
+ if ("root" in val || "commonjs" in val || "amd" in val) {
249
253
  // Standard webpack externals object format
250
- if (value.commonjs) {
251
- externals[key] = `commonjs ${value.commonjs}`;
254
+ if (val.commonjs) {
255
+ externals[key] = `commonjs ${val.commonjs}`;
252
256
  }
253
- else if (value.root) {
254
- externals[key] = value.root;
257
+ else if (val.root) {
258
+ externals[key] = val.root;
255
259
  }
256
- else if (value.amd) {
257
- externals[key] = value.amd;
260
+ else if (val.amd) {
261
+ externals[key] = val.amd;
258
262
  }
259
263
  else {
260
264
  externals[key] = key;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@utoo/pack-shared",
3
- "version": "1.1.11-rc.0",
3
+ "version": "1.1.12",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "types": "esm/index.d.ts",
@@ -31,7 +31,6 @@
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/babel__code-frame": "7.0.2",
34
- "@types/webpack": "^5.28.5",
35
34
  "typescript": "^5.8.3"
36
35
  },
37
36
  "engines": {