@rsbuild/core 0.0.21 → 0.0.23

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.
Files changed (56) hide show
  1. package/bin/rsbuild.js +1 -1
  2. package/compiled/commander/index.js +1 -0
  3. package/compiled/commander/license +22 -0
  4. package/compiled/commander/package.json +1 -0
  5. package/compiled/commander/typings/index.d.ts +889 -0
  6. package/compiled/connect-history-api-fallback/index.d.ts +1 -0
  7. package/compiled/connect-history-api-fallback/index.js +1 -0
  8. package/compiled/connect-history-api-fallback/license +21 -0
  9. package/compiled/connect-history-api-fallback/package.json +1 -0
  10. package/compiled/http-compression/index.d.ts +1 -0
  11. package/compiled/http-compression/index.js +1 -0
  12. package/compiled/http-compression/package.json +1 -0
  13. package/compiled/open/index.d.ts +153 -0
  14. package/compiled/open/index.js +1 -0
  15. package/compiled/open/license +9 -0
  16. package/compiled/open/package.json +1 -0
  17. package/compiled/open/xdg-open +1066 -0
  18. package/dist/cli/commands.js +1 -1
  19. package/dist/cli/config.d.ts +2 -8
  20. package/dist/cli/config.js +0 -18
  21. package/dist/cli/run.d.ts +1 -1
  22. package/dist/cli/run.js +0 -2
  23. package/dist/client/hmr.js +418 -0
  24. package/dist/createRsbuild.js +0 -1
  25. package/dist/index.d.ts +2 -2
  26. package/dist/plugins/fileSize.js +2 -2
  27. package/dist/plugins/html.js +1 -1
  28. package/dist/plugins/index.js +0 -1
  29. package/dist/plugins/startUrl.js +1 -1
  30. package/dist/rspack-provider/core/createCompiler.d.ts +1 -1
  31. package/dist/rspack-provider/core/createCompiler.js +3 -3
  32. package/dist/rspack-provider/core/createContext.js +3 -2
  33. package/dist/rspack-provider/core/rspackConfig.js +1 -1
  34. package/dist/rspack-provider/index.d.ts +1 -1
  35. package/dist/rspack-provider/plugins/css.js +3 -10
  36. package/dist/rspack-provider/plugins/{rspack-profile.js → rspackProfile.js} +3 -3
  37. package/dist/rspack-provider/plugins/swc.js +1 -1
  38. package/dist/rspack-provider/provider.js +6 -5
  39. package/dist/rspack-provider/shared/plugin.js +1 -4
  40. package/dist/rspack-provider/types/plugin.d.ts +1 -1
  41. package/dist/server/dev-middleware/index.d.ts +2 -0
  42. package/dist/server/dev-middleware/index.js +10 -9
  43. package/dist/server/devServer.d.ts +2 -2
  44. package/dist/server/devServer.js +16 -16
  45. package/dist/server/prodServer.d.ts +1 -1
  46. package/dist/server/prodServer.js +2 -2
  47. package/package.json +7 -15
  48. package/dist/plugins/rem.d.ts +0 -2
  49. package/dist/plugins/rem.js +0 -103
  50. package/dist/rspack-provider/plugins/fallback.d.ts +0 -2
  51. package/dist/rspack-provider/plugins/fallback.js +0 -52
  52. package/dist/server/dev-middleware/hmr-client/createSocketUrl.js +0 -68
  53. package/dist/server/dev-middleware/hmr-client/index.js +0 -141
  54. /package/dist/{server/dev-middleware/hmr-client → client/hmr}/createSocketUrl.d.ts +0 -0
  55. /package/dist/{server/dev-middleware/hmr-client → client/hmr}/index.d.ts +0 -0
  56. /package/dist/rspack-provider/plugins/{rspack-profile.d.ts → rspackProfile.d.ts} +0 -0
@@ -1,141 +0,0 @@
1
- "use strict";
2
- var import_format_stats = require("@rsbuild/shared/format-stats");
3
- var import_createSocketUrl = require("./createSocketUrl");
4
- const hadRuntimeError = false;
5
- const socketUrl = (0, import_createSocketUrl.createSocketUrl)(__resourceQuery);
6
- const connection = new WebSocket(socketUrl);
7
- connection.onopen = function() {
8
- if (typeof console !== "undefined" && typeof console.info === "function") {
9
- console.info("[HMR] connected.");
10
- }
11
- };
12
- connection.onclose = function() {
13
- if (typeof console !== "undefined" && typeof console.info === "function") {
14
- console.info("[HMR] disconnected. Refresh the page if necessary.");
15
- }
16
- };
17
- let isFirstCompilation = true;
18
- let mostRecentCompilationHash = null;
19
- let hasCompileErrors = false;
20
- function clearOutdatedErrors() {
21
- if (typeof console !== "undefined" && typeof console.clear === "function") {
22
- if (hasCompileErrors) {
23
- console.clear();
24
- }
25
- }
26
- }
27
- function handleSuccess() {
28
- clearOutdatedErrors();
29
- const isHotUpdate = !isFirstCompilation;
30
- isFirstCompilation = false;
31
- hasCompileErrors = false;
32
- if (isHotUpdate) {
33
- tryApplyUpdates();
34
- }
35
- }
36
- function handleWarnings(warnings) {
37
- clearOutdatedErrors();
38
- const isHotUpdate = !isFirstCompilation;
39
- isFirstCompilation = false;
40
- hasCompileErrors = false;
41
- function printWarnings() {
42
- const formatted = (0, import_format_stats.formatStatsMessages)({
43
- warnings,
44
- errors: []
45
- });
46
- if (typeof console !== "undefined" && typeof console.warn === "function") {
47
- for (let i = 0; i < formatted.warnings.length; i++) {
48
- if (i === 5) {
49
- console.warn(
50
- "There were more warnings in other files.\nYou can find a complete log in the terminal."
51
- );
52
- break;
53
- }
54
- console.warn(formatted.warnings[i]);
55
- }
56
- }
57
- }
58
- printWarnings();
59
- if (isHotUpdate) {
60
- tryApplyUpdates();
61
- }
62
- }
63
- function handleErrors(errors) {
64
- clearOutdatedErrors();
65
- isFirstCompilation = false;
66
- hasCompileErrors = true;
67
- const formatted = (0, import_format_stats.formatStatsMessages)({
68
- errors,
69
- warnings: []
70
- });
71
- if (typeof console !== "undefined" && typeof console.error === "function") {
72
- for (const error of formatted.errors) {
73
- console.error(error);
74
- }
75
- }
76
- }
77
- function handleAvailableHash(hash) {
78
- mostRecentCompilationHash = hash;
79
- }
80
- connection.onmessage = function(e) {
81
- const message = JSON.parse(e.data);
82
- switch (message.type) {
83
- case "hash":
84
- handleAvailableHash(message.data);
85
- break;
86
- case "still-ok":
87
- case "ok":
88
- handleSuccess();
89
- break;
90
- case "content-changed":
91
- window.location.reload();
92
- break;
93
- case "warnings":
94
- handleWarnings(message.data);
95
- break;
96
- case "errors":
97
- handleErrors(message.data);
98
- break;
99
- default:
100
- }
101
- };
102
- function isUpdateAvailable() {
103
- return mostRecentCompilationHash !== __webpack_hash__;
104
- }
105
- function canApplyUpdates() {
106
- return module.hot.status() === "idle";
107
- }
108
- function tryApplyUpdates() {
109
- if (!module.hot) {
110
- window.location.reload();
111
- return;
112
- }
113
- if (!isUpdateAvailable() || !canApplyUpdates()) {
114
- return;
115
- }
116
- function handleApplyUpdates(err, updatedModules) {
117
- const wantsForcedReload = err || !updatedModules || hadRuntimeError;
118
- if (wantsForcedReload) {
119
- window.location.reload();
120
- return;
121
- }
122
- if (isUpdateAvailable()) {
123
- tryApplyUpdates();
124
- }
125
- }
126
- const result = module.hot.check(
127
- /* autoApply */
128
- true,
129
- handleApplyUpdates
130
- );
131
- if (result == null ? void 0 : result.then) {
132
- result.then(
133
- (updatedModules) => {
134
- handleApplyUpdates(null, updatedModules);
135
- },
136
- (err) => {
137
- handleApplyUpdates(err, null);
138
- }
139
- );
140
- }
141
- }