@modern-js/runtime 0.0.0-next-20231103035405 → 0.0.0-next-20231103131234

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.
@@ -52,17 +52,6 @@ const checkIsInline = (chunk, enableInline) => {
52
52
  return false;
53
53
  }
54
54
  };
55
- const readAsset = async (chunk) => {
56
- const fs = await Promise.resolve().then(() => __toESM(require("node:fs/promises")));
57
- const path = await Promise.resolve().then(() => __toESM(require("node:path")));
58
- let filepath;
59
- if (process.env.NODE_ENV === "production") {
60
- filepath = path.resolve(__dirname, chunk.filename);
61
- } else {
62
- filepath = chunk.path;
63
- }
64
- return fs.readFile(filepath, "utf-8");
65
- };
66
55
  const checkIsNode = () => {
67
56
  var _process_release;
68
57
  return typeof process !== "undefined" && ((_process_release = process.release) === null || _process_release === void 0 ? void 0 : _process_release.name) === "node";
@@ -125,13 +114,14 @@ class LoadableCollector {
125
114
  const jsChunkReg = new RegExp(`<script .*src="${chunk.url}".*>`);
126
115
  return !jsChunkReg.test(template) && !((_this_existsAssets = this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
127
116
  }).map(async (chunk) => {
128
- const script = `<script${attributes} src="${chunk.url}"></script>`;
129
117
  if (checkIsInline(chunk, enableInlineScripts) && checkIsNode()) {
130
- return readAsset(chunk).then((content) => `<script>${content}</script>`).catch((_) => {
131
- return script;
118
+ const fs = await Promise.resolve().then(() => __toESM(require("node:fs/promises")));
119
+ const filepath = chunk.path;
120
+ return fs.readFile(filepath, "utf-8").then((content) => `<script>${content}</script>`).catch((_) => {
121
+ return "";
132
122
  });
133
123
  } else {
134
- return script;
124
+ return `<script${attributes} src="${chunk.url}"></script>`;
135
125
  }
136
126
  }));
137
127
  chunksMap.js += scripts.filter((script) => Boolean(script)).join("");
@@ -144,13 +134,13 @@ class LoadableCollector {
144
134
  const cssChunkReg = new RegExp(`<link .*href="${chunk.url}".*>`);
145
135
  return !cssChunkReg.test(template) && !((_this_existsAssets = this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
146
136
  }).map(async (chunk) => {
147
- const link = `<link${atrributes} href="${chunk.url}" rel="stylesheet" />`;
148
137
  if (checkIsInline(chunk, enableInlineStyles) && checkIsNode()) {
149
- return readAsset(chunk).then((content) => `<style>${content}</style>`).catch((_) => {
150
- return link;
138
+ const fs = await Promise.resolve().then(() => __toESM(require("node:fs/promises")));
139
+ return fs.readFile(chunk.path).then((content) => `<style>${content}</style>`).catch((_) => {
140
+ return "";
151
141
  });
152
142
  } else {
153
- return link;
143
+ return `<link${atrributes} href="${chunk.url}" rel="stylesheet" />`;
154
144
  }
155
145
  }));
156
146
  chunksMap.css += css.filter((css2) => Boolean(css2)).join("");
@@ -31,40 +31,6 @@ var checkIsInline = function(chunk, enableInline) {
31
31
  return false;
32
32
  }
33
33
  };
34
- var readAsset = function() {
35
- var _ref = _async_to_generator(function(chunk) {
36
- var fs, path, filepath;
37
- return _ts_generator(this, function(_state) {
38
- switch (_state.label) {
39
- case 0:
40
- return [
41
- 4,
42
- import("node:fs/promises")
43
- ];
44
- case 1:
45
- fs = _state.sent();
46
- return [
47
- 4,
48
- import("node:path")
49
- ];
50
- case 2:
51
- path = _state.sent();
52
- if (process.env.NODE_ENV === "production") {
53
- filepath = path.resolve(__dirname, chunk.filename);
54
- } else {
55
- filepath = chunk.path;
56
- }
57
- return [
58
- 2,
59
- fs.readFile(filepath, "utf-8")
60
- ];
61
- }
62
- });
63
- });
64
- return function readAsset2(chunk) {
65
- return _ref.apply(this, arguments);
66
- };
67
- }();
68
34
  var checkIsNode = function() {
69
35
  var _process_release;
70
36
  return typeof process !== "undefined" && ((_process_release = process.release) === null || _process_release === void 0 ? void 0 : _process_release.name) === "node";
@@ -185,27 +151,40 @@ var LoadableCollector = /* @__PURE__ */ function() {
185
151
  return !jsChunkReg.test(template) && !((_this_existsAssets = _this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
186
152
  }).map(function() {
187
153
  var _ref = _async_to_generator(function(chunk) {
188
- var script;
154
+ var fs, filepath;
189
155
  return _ts_generator(this, function(_state2) {
190
- script = "<script".concat(attributes, ' src="').concat(chunk.url, '"></script>');
191
- if (checkIsInline(chunk, enableInlineScripts) && checkIsNode()) {
192
- return [
193
- 2,
194
- readAsset(chunk).then(function(content) {
195
- return "<script>".concat(content, "</script>");
196
- }).catch(function(_) {
197
- return script;
198
- })
199
- ];
200
- } else {
201
- return [
202
- 2,
203
- script
204
- ];
156
+ switch (_state2.label) {
157
+ case 0:
158
+ if (!(checkIsInline(chunk, enableInlineScripts) && checkIsNode()))
159
+ return [
160
+ 3,
161
+ 2
162
+ ];
163
+ return [
164
+ 4,
165
+ import("node:fs/promises")
166
+ ];
167
+ case 1:
168
+ fs = _state2.sent();
169
+ filepath = chunk.path;
170
+ return [
171
+ 2,
172
+ fs.readFile(filepath, "utf-8").then(function(content) {
173
+ return "<script>".concat(content, "</script>");
174
+ }).catch(function(_) {
175
+ return "";
176
+ })
177
+ ];
178
+ case 2:
179
+ return [
180
+ 2,
181
+ "<script".concat(attributes, ' src="').concat(chunk.url, '"></script>')
182
+ ];
183
+ case 3:
184
+ return [
185
+ 2
186
+ ];
205
187
  }
206
- return [
207
- 2
208
- ];
209
188
  });
210
189
  });
211
190
  return function(chunk) {
@@ -245,27 +224,39 @@ var LoadableCollector = /* @__PURE__ */ function() {
245
224
  return !cssChunkReg.test(template) && !((_this_existsAssets = _this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
246
225
  }).map(function() {
247
226
  var _ref = _async_to_generator(function(chunk) {
248
- var link;
227
+ var fs;
249
228
  return _ts_generator(this, function(_state2) {
250
- link = "<link".concat(atrributes, ' href="').concat(chunk.url, '" rel="stylesheet" />');
251
- if (checkIsInline(chunk, enableInlineStyles) && checkIsNode()) {
252
- return [
253
- 2,
254
- readAsset(chunk).then(function(content) {
255
- return "<style>".concat(content, "</style>");
256
- }).catch(function(_) {
257
- return link;
258
- })
259
- ];
260
- } else {
261
- return [
262
- 2,
263
- link
264
- ];
229
+ switch (_state2.label) {
230
+ case 0:
231
+ if (!(checkIsInline(chunk, enableInlineStyles) && checkIsNode()))
232
+ return [
233
+ 3,
234
+ 2
235
+ ];
236
+ return [
237
+ 4,
238
+ import("node:fs/promises")
239
+ ];
240
+ case 1:
241
+ fs = _state2.sent();
242
+ return [
243
+ 2,
244
+ fs.readFile(chunk.path).then(function(content) {
245
+ return "<style>".concat(content, "</style>");
246
+ }).catch(function(_) {
247
+ return "";
248
+ })
249
+ ];
250
+ case 2:
251
+ return [
252
+ 2,
253
+ "<link".concat(atrributes, ' href="').concat(chunk.url, '" rel="stylesheet" />')
254
+ ];
255
+ case 3:
256
+ return [
257
+ 2
258
+ ];
265
259
  }
266
- return [
267
- 2
268
- ];
269
260
  });
270
261
  });
271
262
  return function(chunk) {
@@ -19,17 +19,6 @@ const checkIsInline = (chunk, enableInline) => {
19
19
  return false;
20
20
  }
21
21
  };
22
- const readAsset = async (chunk) => {
23
- const fs = await import("node:fs/promises");
24
- const path = await import("node:path");
25
- let filepath;
26
- if (process.env.NODE_ENV === "production") {
27
- filepath = path.resolve(__dirname, chunk.filename);
28
- } else {
29
- filepath = chunk.path;
30
- }
31
- return fs.readFile(filepath, "utf-8");
32
- };
33
22
  const checkIsNode = () => {
34
23
  var _process_release;
35
24
  return typeof process !== "undefined" && ((_process_release = process.release) === null || _process_release === void 0 ? void 0 : _process_release.name) === "node";
@@ -92,13 +81,14 @@ class LoadableCollector {
92
81
  const jsChunkReg = new RegExp(`<script .*src="${chunk.url}".*>`);
93
82
  return !jsChunkReg.test(template) && !((_this_existsAssets = this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
94
83
  }).map(async (chunk) => {
95
- const script = `<script${attributes} src="${chunk.url}"></script>`;
96
84
  if (checkIsInline(chunk, enableInlineScripts) && checkIsNode()) {
97
- return readAsset(chunk).then((content) => `<script>${content}</script>`).catch((_) => {
98
- return script;
85
+ const fs = await import("node:fs/promises");
86
+ const filepath = chunk.path;
87
+ return fs.readFile(filepath, "utf-8").then((content) => `<script>${content}</script>`).catch((_) => {
88
+ return "";
99
89
  });
100
90
  } else {
101
- return script;
91
+ return `<script${attributes} src="${chunk.url}"></script>`;
102
92
  }
103
93
  }));
104
94
  chunksMap.js += scripts.filter((script) => Boolean(script)).join("");
@@ -111,13 +101,13 @@ class LoadableCollector {
111
101
  const cssChunkReg = new RegExp(`<link .*href="${chunk.url}".*>`);
112
102
  return !cssChunkReg.test(template) && !((_this_existsAssets = this.existsAssets) === null || _this_existsAssets === void 0 ? void 0 : _this_existsAssets.includes(chunk.path));
113
103
  }).map(async (chunk) => {
114
- const link = `<link${atrributes} href="${chunk.url}" rel="stylesheet" />`;
115
104
  if (checkIsInline(chunk, enableInlineStyles) && checkIsNode()) {
116
- return readAsset(chunk).then((content) => `<style>${content}</style>`).catch((_) => {
117
- return link;
105
+ const fs = await import("node:fs/promises");
106
+ return fs.readFile(chunk.path).then((content) => `<style>${content}</style>`).catch((_) => {
107
+ return "";
118
108
  });
119
109
  } else {
120
- return link;
110
+ return `<link${atrributes} href="${chunk.url}" rel="stylesheet" />`;
121
111
  }
122
112
  }));
123
113
  chunksMap.css += css.filter((css2) => Boolean(css2)).join("");
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "0.0.0-next-20231103035405",
18
+ "version": "0.0.0-next-20231103131234",
19
19
  "engines": {
20
20
  "node": ">=14.17.6"
21
21
  },
@@ -171,10 +171,10 @@
171
171
  "react-side-effect": "^2.1.1",
172
172
  "styled-components": "^5.3.1",
173
173
  "@swc/helpers": "0.5.1",
174
- "@modern-js/plugin": "0.0.0-next-20231103035405",
175
- "@modern-js/types": "0.0.0-next-20231103035405",
176
- "@modern-js/utils": "0.0.0-next-20231103035405",
177
- "@modern-js/runtime-utils": "0.0.0-next-20231103035405"
174
+ "@modern-js/plugin": "0.0.0-next-20231103131234",
175
+ "@modern-js/utils": "0.0.0-next-20231103131234",
176
+ "@modern-js/types": "0.0.0-next-20231103131234",
177
+ "@modern-js/runtime-utils": "0.0.0-next-20231103131234"
178
178
  },
179
179
  "peerDependencies": {
180
180
  "react": ">=17",
@@ -195,11 +195,11 @@
195
195
  "ts-jest": "^29.1.0",
196
196
  "typescript": "^5",
197
197
  "webpack": "^5.88.1",
198
- "@modern-js/app-tools": "0.0.0-next-20231103035405",
199
- "@modern-js/core": "0.0.0-next-20231103035405",
200
- "@modern-js/server-core": "0.0.0-next-20231103035405",
201
- "@scripts/build": "0.0.0-next-20231103035405",
202
- "@scripts/jest-config": "0.0.0-next-20231103035405"
198
+ "@modern-js/app-tools": "0.0.0-next-20231103131234",
199
+ "@modern-js/core": "0.0.0-next-20231103131234",
200
+ "@modern-js/server-core": "0.0.0-next-20231103131234",
201
+ "@scripts/build": "0.0.0-next-20231103131234",
202
+ "@scripts/jest-config": "0.0.0-next-20231103131234"
203
203
  },
204
204
  "sideEffects": false,
205
205
  "publishConfig": {