@umijs/bundler-webpack 4.0.0-beta.1 → 4.0.0-beta.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.
@@ -9,7 +9,9 @@ exports.keepAlive = function (options) {
9
9
  var active = options.active;
10
10
  var module = options.module;
11
11
  var response;
12
- var request = require("http").request(
12
+ var request = (
13
+ urlBase.startsWith("https") ? require("https") : require("http")
14
+ ).request(
13
15
  urlBase + data,
14
16
  {
15
17
  agent: false,
@@ -1 +1,5 @@
1
- {"name":"webpack","author":"Tobias Koppers @sokra","license":"MIT","types":"types.d.ts"}
1
+ {
2
+ "name": "webpack",
3
+ "author": "Tobias Koppers @sokra",
4
+ "types": "types.d.ts"
5
+ }
@@ -80,6 +80,8 @@ import {
80
80
  WithStatement,
81
81
  YieldExpression
82
82
  } from "estree";
83
+ import { ServerOptions as ServerOptionsImport } from 'http';
84
+ import { ListenOptions, Server } from 'net';
83
85
  import { validate as validateFunction } from './schema-utils';
84
86
  import { default as ValidationError } from './schema-utils/declarations/ValidationError';
85
87
  import { ValidationErrorConfiguration } from './schema-utils/declarations/validate';
@@ -95,6 +97,7 @@ import {
95
97
  SyncHook,
96
98
  SyncWaterfallHook
97
99
  } from "tapable";
100
+ import { SecureContextOptions, TlsOptions } from 'tls';
98
101
 
99
102
  declare class AbstractLibraryPlugin<T> {
100
103
  constructor(__0: {
@@ -383,6 +386,10 @@ declare class AutomaticPrefetchPlugin {
383
386
  apply(compiler: Compiler): void;
384
387
  }
385
388
  type AuxiliaryComment = string | LibraryCustomUmdCommentObject;
389
+ declare interface BackendApi {
390
+ dispose: (arg0?: Error) => void;
391
+ module: (arg0: Module) => { client: string; data: string; active: boolean };
392
+ }
386
393
  declare class BannerPlugin {
387
394
  constructor(options: BannerPluginArgument);
388
395
  options: BannerPluginOptions;
@@ -5794,25 +5801,45 @@ declare interface KnownStatsProfile {
5794
5801
  dependencies: number;
5795
5802
  }
5796
5803
 
5804
+ /**
5805
+ * Options for the default backend.
5806
+ */
5807
+ declare interface LazyCompilationDefaultBackendOptions {
5808
+ /**
5809
+ * A custom client.
5810
+ */
5811
+ client?: string;
5812
+
5813
+ /**
5814
+ * Specifies where to listen to from the server.
5815
+ */
5816
+ listen?: number | ListenOptions | ((server: typeof Server) => void);
5817
+
5818
+ /**
5819
+ * Specifies the protocol the client should use to connect to the server.
5820
+ */
5821
+ protocol?: "http" | "https";
5822
+
5823
+ /**
5824
+ * Specifies how to create the server handling the EventSource requests.
5825
+ */
5826
+ server?: ServerOptionsImport | ServerOptionsHttps | (() => typeof Server);
5827
+ }
5828
+
5797
5829
  /**
5798
5830
  * Options for compiling entrypoints and import()s only when they are accessed.
5799
5831
  */
5800
5832
  declare interface LazyCompilationOptions {
5801
5833
  /**
5802
- * A custom backend.
5834
+ * Specifies the backend that should be used for handling client keep alive.
5803
5835
  */
5804
5836
  backend?:
5805
5837
  | ((
5806
5838
  compiler: Compiler,
5807
- client: string,
5808
- callback: (err?: Error, api?: any) => void
5839
+ callback: (err?: Error, api?: BackendApi) => void
5809
5840
  ) => void)
5810
- | ((compiler: Compiler, client: string) => Promise<any>);
5811
-
5812
- /**
5813
- * A custom client.
5814
- */
5815
- client?: string;
5841
+ | ((compiler: Compiler) => Promise<BackendApi>)
5842
+ | LazyCompilationDefaultBackendOptions;
5816
5843
 
5817
5844
  /**
5818
5845
  * Enable/disable lazy compilation for entries.
@@ -7485,6 +7512,7 @@ declare interface NormalModuleLoaderContext<OptionsType> {
7485
7512
  utils: {
7486
7513
  absolutify: (context: string, request: string) => string;
7487
7514
  contextify: (context: string, request: string) => string;
7515
+ createHash: (algorithm?: string) => Hash;
7488
7516
  };
7489
7517
  rootContext: string;
7490
7518
  fs: InputFileSystem;
@@ -10369,6 +10397,9 @@ declare abstract class Serializer {
10369
10397
  serialize(obj?: any, context?: any): any;
10370
10398
  deserialize(value?: any, context?: any): any;
10371
10399
  }
10400
+ type ServerOptionsHttps = SecureContextOptions &
10401
+ TlsOptions &
10402
+ ServerOptionsImport;
10372
10403
  declare class SharePlugin {
10373
10404
  constructor(options: SharePluginOptions);
10374
10405
 
package/dist/build.d.ts CHANGED
@@ -4,6 +4,12 @@ interface IOpts {
4
4
  entry: Record<string, string>;
5
5
  config: IConfig;
6
6
  onBuildComplete?: Function;
7
+ babelPreset?: any;
8
+ chainWebpack?: Function;
9
+ beforeBabelPlugins?: any[];
10
+ beforeBabelPresets?: any[];
11
+ extraBabelPlugins?: any[];
12
+ extraBabelPresets?: any[];
7
13
  clean?: boolean;
8
14
  }
9
15
  export declare function build(opts: IOpts): Promise<void>;
package/dist/build.js CHANGED
@@ -25,6 +25,16 @@ function build(opts) {
25
25
  entry: opts.entry,
26
26
  userConfig: opts.config,
27
27
  analyze: process.env.ANALYZE,
28
+ babelPreset: opts.babelPreset,
29
+ extraBabelPlugins: [
30
+ ...(opts.beforeBabelPlugins || []),
31
+ ...(opts.extraBabelPlugins || []),
32
+ ],
33
+ extraBabelPresets: [
34
+ ...(opts.beforeBabelPresets || []),
35
+ ...(opts.extraBabelPresets || []),
36
+ ],
37
+ chainWebpack: opts.chainWebpack,
28
38
  });
29
39
  let isFirstCompile = true;
30
40
  return new Promise((resolve, reject) => {
@@ -42,7 +42,8 @@ function addAssetRules(opts) {
42
42
  });
43
43
  rule
44
44
  .oneOf('fallback')
45
- .exclude.add(/\.(js|mjs|jsx|ts|tsx)$/)
45
+ .exclude.add(/^$/) /* handle data: resources */
46
+ .add(/\.(js|mjs|jsx|ts|tsx)$/)
46
47
  .add(/\.(css|less|sass|scss|stylus)$/)
47
48
  .add(/\.html$/)
48
49
  .add(/\.json$/)
@@ -4,7 +4,10 @@ interface IOpts {
4
4
  cwd: string;
5
5
  env: Env;
6
6
  entry: Record<string, string>;
7
+ extraBabelPresets?: any[];
7
8
  extraBabelPlugins?: any[];
9
+ babelPreset?: any;
10
+ chainWebpack?: Function;
8
11
  hash?: boolean;
9
12
  hmr?: boolean;
10
13
  staticPathPrefix?: string;
@@ -47,7 +47,9 @@ function getConfig(opts) {
47
47
  userConfig,
48
48
  cwd: opts.cwd,
49
49
  env: opts.env,
50
+ babelPreset: opts.babelPreset,
50
51
  extraBabelPlugins: opts.extraBabelPlugins || [],
52
+ extraBabelPresets: opts.extraBabelPresets || [],
51
53
  browsers: (0, browsersList_1.getBrowsersList)({
52
54
  targets: userConfig.targets,
53
55
  }),
@@ -145,6 +147,12 @@ function getConfig(opts) {
145
147
  yield (0, bundleAnalyzerPlugin_1.addBundleAnalyzerPlugin)(applyOpts);
146
148
  }
147
149
  // chain webpack
150
+ if (opts.chainWebpack) {
151
+ yield opts.chainWebpack(config, {
152
+ env: opts.env,
153
+ webpack: webpack_1.default,
154
+ });
155
+ }
148
156
  if (userConfig.chainWebpack) {
149
157
  yield userConfig.chainWebpack(config, {
150
158
  env: opts.env,
@@ -14,10 +14,10 @@ function addCSSRules(opts) {
14
14
  return __awaiter(this, void 0, void 0, function* () {
15
15
  const { config, userConfig } = opts;
16
16
  const rulesConfig = [
17
- { name: 'css', test: /\.css(\?.*)?/ },
17
+ { name: 'css', test: /\.css(\?.*)?$/ },
18
18
  {
19
19
  name: 'less',
20
- test: /\.less(\?.*)?/,
20
+ test: /\.less(\?.*)?$/,
21
21
  loader: require.resolve('@umijs/bundler-webpack/compiled/less-loader'),
22
22
  loaderOptions: {
23
23
  implementation: require.resolve('@umijs/bundler-webpack/compiled/less'),
@@ -26,7 +26,7 @@ function addCSSRules(opts) {
26
26
  },
27
27
  {
28
28
  name: 'sass',
29
- test: /\.(sass|scss)(\?.*)?/,
29
+ test: /\.(sass|scss)(\?.*)?$/,
30
30
  loader: require.resolve('@umijs/bundler-webpack/compiled/sass-loader'),
31
31
  loaderOptions: userConfig.sassLoader || {},
32
32
  },
@@ -6,6 +6,8 @@ interface IOpts {
6
6
  cwd: string;
7
7
  env: Env;
8
8
  extraBabelPlugins: any[];
9
+ extraBabelPresets: any[];
10
+ babelPreset: any;
9
11
  name?: string;
10
12
  }
11
13
  export declare function addJavaScriptRules(opts: IOpts): Promise<void>;
@@ -85,10 +85,9 @@ function addJavaScriptRules(opts) {
85
85
  // : false,
86
86
  targets: userConfig.targets,
87
87
  presets: [
88
- [
88
+ opts.babelPreset || [
89
89
  require.resolve('@umijs/babel-preset-umi'),
90
90
  {
91
- env,
92
91
  presetEnv: {},
93
92
  presetReact: {},
94
93
  presetTypeScript: {},
@@ -98,6 +97,7 @@ function addJavaScriptRules(opts) {
98
97
  pluginAutoCSSModules: userConfig.autoCSSModules,
99
98
  },
100
99
  ],
100
+ ...opts.extraBabelPresets,
101
101
  ...(userConfig.extraBabelPresets || []).filter(Boolean),
102
102
  ],
103
103
  plugins: [
package/dist/dev.d.ts CHANGED
@@ -5,6 +5,11 @@ interface IOpts {
5
5
  onDevCompileDone?: Function;
6
6
  port?: number;
7
7
  host?: string;
8
+ chainWebpack?: Function;
9
+ beforeBabelPlugins?: any[];
10
+ beforeBabelPresets?: any[];
11
+ extraBabelPlugins?: any[];
12
+ extraBabelPresets?: any[];
8
13
  cwd: string;
9
14
  config: IConfig;
10
15
  entry: Record<string, string>;
package/dist/dev.js CHANGED
@@ -30,7 +30,16 @@ function dev(opts) {
30
30
  env: types_1.Env.development,
31
31
  entry: opts.entry,
32
32
  userConfig: opts.config,
33
- extraBabelPlugins: mfsu.getBabelPlugins(),
33
+ extraBabelPlugins: [
34
+ ...(opts.beforeBabelPlugins || []),
35
+ ...mfsu.getBabelPlugins(),
36
+ ...(opts.extraBabelPlugins || []),
37
+ ],
38
+ extraBabelPresets: [
39
+ ...(opts.beforeBabelPresets || []),
40
+ ...(opts.extraBabelPresets || []),
41
+ ],
42
+ chainWebpack: opts.chainWebpack,
34
43
  hmr: true,
35
44
  analyze: process.env.ANALYZE,
36
45
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/bundler-webpack",
3
- "version": "4.0.0-beta.1",
3
+ "version": "4.0.0-beta.5",
4
4
  "description": "@umijs/bundler-webpack",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -37,10 +37,10 @@
37
37
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.1",
38
38
  "@swc/core": "1.2.105",
39
39
  "@types/hapi__joi": "17.1.7",
40
- "@umijs/babel-preset-umi": "4.0.0-beta.1",
41
- "@umijs/mfsu": "4.0.0-beta.1",
42
- "@umijs/utils": "4.0.0-beta.1",
43
- "css-loader": "6.4.0",
40
+ "@umijs/babel-preset-umi": "4.0.0-beta.5",
41
+ "@umijs/mfsu": "4.0.0-beta.5",
42
+ "@umijs/utils": "4.0.0-beta.5",
43
+ "css-loader": "6.5.0",
44
44
  "es5-imcompatible-versions": "^0.1.73",
45
45
  "jest-worker": "27.3.1",
46
46
  "node-libs-browser": "2.2.1",
@@ -79,7 +79,7 @@
79
79
  "terser": "5.9.0",
80
80
  "terser-webpack-plugin": "5.2.4",
81
81
  "url-loader": "4.1.1",
82
- "webpack": "5.59.0",
82
+ "webpack": "5.61.0",
83
83
  "webpack-5-chain": "8.0.0",
84
84
  "webpack-bundle-analyzer": "4.5.0",
85
85
  "webpack-dev-middleware": "5.2.1",