@dtwo/webpack-builder 3.1.2 → 3.2.1

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2022 - Dtwo Team
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 - Dtwo Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import pify from 'pify';
2
- import webpack from 'webpack';
2
+ import webpack, { RuntimeGlobals } from 'webpack';
3
3
  import { fromNodeMiddleware, defineEventHandler } from 'h3';
4
4
  import webpackDevMiddleware from 'webpack-dev-middleware';
5
5
  import webpackHotMiddleware from 'webpack-hot-middleware';
@@ -16,19 +16,19 @@ import { createFsFromVolume, Volume } from 'memfs';
16
16
  import VirtualModulesPlugin from 'webpack-virtual-modules';
17
17
  import querystring from 'node:querystring';
18
18
  import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
19
+ import ForkTSCheckerWebpackPlugin from '@dtwojs/fork-ts-checker-webpack-plugin';
19
20
  import { cloneDeep, uniq, defaults as defaults$1, merge } from 'lodash-es';
20
21
  import TimeFixPlugin from 'time-fix-plugin';
21
22
  import WebpackBar from 'webpackbar';
22
23
  import FriendlyErrorsWebpackPlugin from '@d2js/friendly-errors-webpack-plugin';
23
24
  import escapeRegExp from 'escape-string-regexp';
24
- import esbuildLoader from 'esbuild-loader';
25
+ import { EsbuildPlugin } from 'esbuild-loader';
25
26
  import KduLoaderPlugin from 'kdu-loader/dist/pluginWebpack5.js';
26
27
  import { normalizeWebpackManifest } from 'kdu-bundle-renderer';
27
28
  import hash$1 from 'hash-sum';
28
29
  import fse from 'fs-extra';
29
30
  import MiniCssExtractPlugin from 'mini-css-extract-plugin';
30
31
  import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
31
- import ForkTSCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
32
32
 
33
33
  const keyedFunctions = [
34
34
  "useState",
@@ -155,6 +155,31 @@ ${options.globalPublicPath} = buildAssetsURL();
155
155
  };
156
156
  });
157
157
 
158
+ const pluginName = "ChunkErrorPlugin";
159
+ const script = `
160
+ if (typeof ${RuntimeGlobals.require} !== "undefined") {
161
+ var _ensureChunk = ${RuntimeGlobals.ensureChunk};
162
+ ${RuntimeGlobals.ensureChunk} = function (chunkId) {
163
+ return Promise.resolve(_ensureChunk(chunkId)).catch(err => {
164
+ const e = new Event("dtwo.preloadError");
165
+ e.payload = err;
166
+ window.dispatchEvent(e);
167
+ throw err;
168
+ });
169
+ };
170
+ };`;
171
+ class ChunkErrorPlugin {
172
+ apply(compiler) {
173
+ compiler.hooks.thisCompilation.tap(
174
+ pluginName,
175
+ (compilation) => compilation.mainTemplate.hooks.localVars.tap(
176
+ { name: pluginName, stage: 1 },
177
+ (source) => source + script
178
+ )
179
+ );
180
+ }
181
+ }
182
+
158
183
  function createMFS() {
159
184
  const fs = createFsFromVolume(new Volume());
160
185
  const _fs = { ...fs };
@@ -471,7 +496,7 @@ function getEnv(ctx) {
471
496
  function esbuild(ctx) {
472
497
  const { config } = ctx;
473
498
  const target = ctx.isServer ? "es2019" : "chrome85";
474
- config.optimization.minimizer.push(new esbuildLoader.ESBuildMinifyPlugin());
499
+ config.optimization.minimizer.push(new EsbuildPlugin());
475
500
  config.module.rules.push(
476
501
  {
477
502
  test: /\.m?[jt]s$/i,
@@ -970,6 +995,18 @@ function clientPlugins(ctx) {
970
995
  ...options.webpack.analyze === true ? {} : options.webpack.analyze
971
996
  }));
972
997
  }
998
+ if (!ctx.dtwo.options.ssr) {
999
+ if (ctx.dtwo.options.typescript.typeCheck === true || ctx.dtwo.options.typescript.typeCheck === "build" && !ctx.dtwo.options.dev) {
1000
+ config.plugins.push(new ForkTSCheckerWebpackPlugin({
1001
+ logger,
1002
+ typescript: {
1003
+ extensions: {
1004
+ kdu: { compiler: "@kdujs/compiler-sfc" }
1005
+ }
1006
+ }
1007
+ }));
1008
+ }
1009
+ }
973
1010
  }
974
1011
 
975
1012
  function node(ctx) {
@@ -1066,7 +1103,14 @@ function serverPlugins(ctx) {
1066
1103
  }));
1067
1104
  }
1068
1105
  if (ctx.dtwo.options.typescript.typeCheck === true || ctx.dtwo.options.typescript.typeCheck === "build" && !ctx.dtwo.options.dev) {
1069
- config.plugins.push(new ForkTSCheckerWebpackPlugin({ logger }));
1106
+ config.plugins.push(new ForkTSCheckerWebpackPlugin({
1107
+ logger,
1108
+ typescript: {
1109
+ extensions: {
1110
+ kdu: { compiler: "@kdujs/compiler-sfc" }
1111
+ }
1112
+ }
1113
+ }));
1070
1114
  }
1071
1115
  }
1072
1116
 
@@ -1083,6 +1127,9 @@ async function bundle(dtwo) {
1083
1127
  config.plugins.push(DynamicBasePlugin.webpack({
1084
1128
  sourcemap: dtwo.options.sourcemap[config.name]
1085
1129
  }));
1130
+ if (config.name === "client" && dtwo.options.experimental.emitRouteChunkError) {
1131
+ config.plugins.push(new ChunkErrorPlugin());
1132
+ }
1086
1133
  config.plugins.push(composableKeysPlugin.webpack({
1087
1134
  sourcemap: dtwo.options.sourcemap[config.name],
1088
1135
  rootDir: dtwo.options.rootDir
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dtwo/webpack-builder",
3
- "version": "3.1.2",
3
+ "version": "3.2.1",
4
4
  "repository": "d2js/dtwo",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -15,26 +15,26 @@
15
15
  "dependencies": {
16
16
  "@babel/core": "7.20.12",
17
17
  "@d2js/friendly-errors-webpack-plugin": "2.5.2",
18
- "@dtwo/kit": "3.1.2",
19
- "@dtwo/unplugin": "1.0.0",
18
+ "@dtwo/kit": "3.2.1",
19
+ "@dtwo/unplugin": "1.4.0",
20
+ "@dtwojs/fork-ts-checker-webpack-plugin": "7.3.0",
20
21
  "autoprefixer": "10.4.13",
21
22
  "css-loader": "6.7.3",
22
23
  "css-minimizer-webpack-plugin": "4.2.2",
23
- "cssnano": "5.1.14",
24
- "esbuild-loader": "2.21.0",
24
+ "cssnano": "5.1.15",
25
+ "esbuild-loader": "3.0.1",
25
26
  "escape-string-regexp": "5.0.0",
26
27
  "estree-walker": "3.0.3",
27
28
  "file-loader": "6.2.0",
28
- "fork-ts-checker-webpack-plugin": "7.3.0",
29
29
  "fs-extra": "11.1.0",
30
30
  "hash-sum": "2.0.0",
31
- "kdu-bundle-renderer": "1.0.0",
31
+ "kdu-bundle-renderer": "1.0.2-1",
32
32
  "kdu-loader": "17.0.0",
33
33
  "lodash-es": "4.17.21",
34
- "magic-string": "0.27.0",
34
+ "magic-string": "0.29.0",
35
35
  "memfs": "3.4.13",
36
36
  "mini-css-extract-plugin": "2.7.2",
37
- "mlly": "1.1.0",
37
+ "mlly": "1.1.1",
38
38
  "ohash": "1.0.0",
39
39
  "pathe": "1.1.0",
40
40
  "pify": "6.1.0",
@@ -44,17 +44,17 @@
44
44
  "postcss-url": "10.1.3",
45
45
  "style-resources-loader": "1.5.0",
46
46
  "time-fix-plugin": "2.0.7",
47
- "ufo": "1.0.1",
47
+ "ufo": "1.1.0",
48
48
  "url-loader": "4.1.1",
49
49
  "webpack": "5.75.0",
50
- "webpack-bundle-analyzer": "4.7.0",
50
+ "webpack-bundle-analyzer": "4.8.0",
51
51
  "webpack-dev-middleware": "6.0.1",
52
52
  "webpack-hot-middleware": "2.25.3",
53
53
  "webpack-virtual-modules": "0.5.0",
54
54
  "webpackbar": "5.0.2"
55
55
  },
56
56
  "devDependencies": {
57
- "@dtwo/schema": "3.1.2",
57
+ "@dtwo/schema": "3.2.1",
58
58
  "@types/lodash-es": "4.17.6",
59
59
  "@types/pify": "5.0.1",
60
60
  "@types/webpack-bundle-analyzer": "4.6.0",
@@ -68,7 +68,7 @@
68
68
  "kdu": "^3.2.47"
69
69
  },
70
70
  "engines": {
71
- "node": "^14.16.0 || ^16.10.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
71
+ "node": "^14.18.0 || ^16.10.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
72
72
  },
73
73
  "scripts": {}
74
74
  }
package/README.md DELETED
@@ -1,7 +0,0 @@
1
- # Dtwo
2
-
3
- Dtwo 3: **The Intuitive Web Framework** ✨
4
-
5
- ## License
6
-
7
- [MIT](./LICENSE)