@nuxt/bridge-edge 3.0.0-27480141.51f3bbf → 3.0.0-27480330.ade3378
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/dist/chunks/module.mjs +23 -2
- package/dist/chunks/module2.mjs +32 -3
- package/dist/chunks/vite.mjs +310 -46
- package/package.json +6 -6
package/dist/chunks/module.mjs
CHANGED
|
@@ -408,6 +408,27 @@ const schemaTemplate = {
|
|
|
408
408
|
].join("\n");
|
|
409
409
|
}
|
|
410
410
|
};
|
|
411
|
+
const clientConfigTemplate = {
|
|
412
|
+
filename: "config.client.mjs",
|
|
413
|
+
getContents: () => "export default window?.__NUXT__?.config || {}"
|
|
414
|
+
};
|
|
415
|
+
const publicPathTemplate = {
|
|
416
|
+
filename: "paths.mjs",
|
|
417
|
+
getContents({ nuxt }) {
|
|
418
|
+
return [
|
|
419
|
+
"import { joinURL } from 'ufo'",
|
|
420
|
+
!nuxt.options.dev && "import config from '#_config'",
|
|
421
|
+
nuxt.options.dev ? `const appConfig = ${JSON.stringify(nuxt.options.app)}` : "const appConfig = config.app",
|
|
422
|
+
"export const baseURL = () => appConfig.baseURL",
|
|
423
|
+
"export const buildAssetsDir = () => appConfig.buildAssetsDir",
|
|
424
|
+
"export const buildAssetsURL = (...path) => joinURL(publicAssetsURL(), buildAssetsDir(), ...path)",
|
|
425
|
+
"export const publicAssetsURL = (...path) => {",
|
|
426
|
+
" const publicBase = appConfig.cdnURL || appConfig.baseURL",
|
|
427
|
+
" return path.length ? joinURL(publicBase, ...path) : publicBase",
|
|
428
|
+
"}"
|
|
429
|
+
].filter(Boolean).join("\n");
|
|
430
|
+
}
|
|
431
|
+
};
|
|
411
432
|
|
|
412
433
|
const VueCompat = createUnplugin((opts) => {
|
|
413
434
|
return {
|
|
@@ -985,7 +1006,7 @@ function addDeclarationTemplates(ctx) {
|
|
|
985
1006
|
});
|
|
986
1007
|
}
|
|
987
1008
|
|
|
988
|
-
const UnsupportedImports = /* @__PURE__ */ new Set(["useAsyncData", "useFetch", "useError", "throwError", "clearError"]);
|
|
1009
|
+
const UnsupportedImports = /* @__PURE__ */ new Set(["useAsyncData", "useFetch", "useError", "throwError", "clearError", "defineNuxtLink"]);
|
|
989
1010
|
const CapiHelpers = new Set(Object.keys(CompositionApi));
|
|
990
1011
|
function setupAutoImports() {
|
|
991
1012
|
const nuxt = useNuxt();
|
|
@@ -1211,4 +1232,4 @@ const module = defineNuxtModule({
|
|
|
1211
1232
|
}
|
|
1212
1233
|
});
|
|
1213
1234
|
|
|
1214
|
-
export { distDir$1 as d, module as m };
|
|
1235
|
+
export { clientConfigTemplate as c, distDir$1 as d, module as m, publicPathTemplate as p };
|
package/dist/chunks/module2.mjs
CHANGED
|
@@ -1,9 +1,33 @@
|
|
|
1
|
-
import { defineNuxtModule, logger, addPluginTemplate } from '@nuxt/kit';
|
|
1
|
+
import { defineNuxtModule, logger, addPluginTemplate, addTemplate } from '@nuxt/kit';
|
|
2
|
+
import { c as clientConfigTemplate, p as publicPathTemplate } from './module.mjs';
|
|
2
3
|
import hash from 'hash-sum';
|
|
3
4
|
import { resolve } from 'pathe';
|
|
4
5
|
import { genImport, genObjectFromRawEntries } from 'knitwork';
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
import 'module';
|
|
7
|
+
import 'fs';
|
|
8
|
+
import 'node-fetch';
|
|
9
|
+
import 'fs-extra';
|
|
10
|
+
import 'ufo';
|
|
11
|
+
import '@nuxt/nitro';
|
|
12
|
+
import 'url';
|
|
13
|
+
import 'path';
|
|
14
|
+
import 'untyped';
|
|
15
|
+
import 'escape-string-regexp';
|
|
16
|
+
import 'magic-string';
|
|
17
|
+
import 'mlly';
|
|
18
|
+
import 'unplugin';
|
|
19
|
+
import 'crypto';
|
|
20
|
+
import 'acorn';
|
|
21
|
+
import 'estree-walker';
|
|
22
|
+
import 'util';
|
|
23
|
+
import 'defu';
|
|
24
|
+
import 'enhanced-resolve';
|
|
25
|
+
import '@vue/composition-api';
|
|
26
|
+
import 'unimport';
|
|
27
|
+
import 'scule';
|
|
28
|
+
import 'unplugin-vue2-script-setup/nuxt';
|
|
29
|
+
|
|
30
|
+
const version = "3.0.0-27480330.ade3378";
|
|
7
31
|
|
|
8
32
|
const middlewareTemplate = {
|
|
9
33
|
filename: "middleware.js",
|
|
@@ -151,6 +175,11 @@ const module = defineNuxtModule({
|
|
|
151
175
|
addPluginTemplate(storeTemplate);
|
|
152
176
|
}
|
|
153
177
|
addPluginTemplate(middlewareTemplate);
|
|
178
|
+
addTemplate(clientConfigTemplate);
|
|
179
|
+
addTemplate({
|
|
180
|
+
...publicPathTemplate,
|
|
181
|
+
options: { nuxt }
|
|
182
|
+
});
|
|
154
183
|
nuxt.hook("builder:prepared", async (builder) => {
|
|
155
184
|
if (nuxt.options._prepare) {
|
|
156
185
|
return;
|
package/dist/chunks/vite.mjs
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
import { resolve, join } from 'pathe';
|
|
2
2
|
import * as vite from 'vite';
|
|
3
|
-
import { logger } from '@nuxt/kit';
|
|
3
|
+
import { logger, isIgnored } from '@nuxt/kit';
|
|
4
|
+
import { findExports, sanitizeFilePath } from 'mlly';
|
|
5
|
+
import { createServer } from 'net';
|
|
6
|
+
import { networkInterfaces } from 'os';
|
|
7
|
+
import fs$1, { existsSync } from 'fs';
|
|
8
|
+
import require$$1 from 'path';
|
|
4
9
|
import { joinURL, withoutLeadingSlash } from 'ufo';
|
|
5
10
|
import { d as distDir } from './module.mjs';
|
|
11
|
+
import { createUnplugin } from 'unplugin';
|
|
12
|
+
import escapeRE from 'escape-string-regexp';
|
|
13
|
+
import MagicString from 'magic-string';
|
|
6
14
|
import { createVuePlugin } from 'vite-plugin-vue2';
|
|
7
15
|
import PluginLegacy from '@vitejs/plugin-legacy';
|
|
8
16
|
import { createHash } from 'crypto';
|
|
9
|
-
import { existsSync } from 'fs';
|
|
10
17
|
import fse from 'fs-extra';
|
|
11
18
|
import { debounce } from 'perfect-debounce';
|
|
12
19
|
import { pathToFileURL } from 'url';
|
|
13
20
|
import { builtinModules } from 'module';
|
|
14
21
|
import { isExternal as isExternal$1, ExternalsDefaults } from 'externality';
|
|
15
22
|
import { genObjectFromRawEntries, genDynamicImport } from 'knitwork';
|
|
16
|
-
import { findExports } from 'mlly';
|
|
17
23
|
import createResolver from 'postcss-import-resolver';
|
|
18
24
|
import defu from 'defu';
|
|
19
25
|
import 'node-fetch';
|
|
20
26
|
import '@nuxt/nitro';
|
|
21
|
-
import 'path';
|
|
22
27
|
import 'untyped';
|
|
23
|
-
import 'escape-string-regexp';
|
|
24
|
-
import 'magic-string';
|
|
25
|
-
import 'unplugin';
|
|
26
28
|
import 'acorn';
|
|
27
29
|
import 'estree-walker';
|
|
28
30
|
import 'util';
|
|
@@ -32,6 +34,156 @@ import 'unimport';
|
|
|
32
34
|
import 'scule';
|
|
33
35
|
import 'unplugin-vue2-script-setup/nuxt';
|
|
34
36
|
|
|
37
|
+
var dist = {};
|
|
38
|
+
|
|
39
|
+
Object.defineProperty(dist, '__esModule', { value: true });
|
|
40
|
+
|
|
41
|
+
const fs = fs$1;
|
|
42
|
+
const path = require$$1;
|
|
43
|
+
|
|
44
|
+
const _memo = {
|
|
45
|
+
_pid: process.pid
|
|
46
|
+
};
|
|
47
|
+
async function getMemo(config) {
|
|
48
|
+
const options = getOptions(config);
|
|
49
|
+
try {
|
|
50
|
+
const memo = JSON.parse(await fs.promises.readFile(options.file, "utf-8")) || {};
|
|
51
|
+
if (!memo._pid) {
|
|
52
|
+
throw new Error("Memo lacks _pid");
|
|
53
|
+
}
|
|
54
|
+
if (memo._pid === _memo._pid || !isAlive(memo.pid)) {
|
|
55
|
+
Object.assign(_memo, memo);
|
|
56
|
+
_memo._pid = process.pid;
|
|
57
|
+
}
|
|
58
|
+
} catch (e) {
|
|
59
|
+
}
|
|
60
|
+
return _memo;
|
|
61
|
+
}
|
|
62
|
+
async function setMemo(memo, config) {
|
|
63
|
+
const options = getOptions(config);
|
|
64
|
+
Object.assign(_memo, memo);
|
|
65
|
+
_memo._pid = process.pid;
|
|
66
|
+
try {
|
|
67
|
+
await fs.promises.mkdir(options.dir);
|
|
68
|
+
} catch (e) {
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
await fs.promises.writeFile(options.file, JSON.stringify(_memo), "utf-8");
|
|
72
|
+
} catch (e) {
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function getOptions(config) {
|
|
76
|
+
const options = {...config};
|
|
77
|
+
options.name = options.name || "default";
|
|
78
|
+
options.dir = options.dir || path.resolve(process.cwd(), "node_modules/.cache/fs-memo");
|
|
79
|
+
options.file = options.file || path.resolve(options.dir, options.name + ".json");
|
|
80
|
+
return options;
|
|
81
|
+
}
|
|
82
|
+
function isAlive(pid) {
|
|
83
|
+
try {
|
|
84
|
+
process.kill(pid, 0);
|
|
85
|
+
return true;
|
|
86
|
+
} catch (e) {
|
|
87
|
+
return e.code === "EPERM";
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
var getMemo_1 = dist.getMemo = getMemo;
|
|
92
|
+
var setMemo_1 = dist.setMemo = setMemo;
|
|
93
|
+
|
|
94
|
+
async function getPort(config) {
|
|
95
|
+
if (typeof config === "number" || typeof config === "string") {
|
|
96
|
+
config = { port: parseInt(config + "") };
|
|
97
|
+
}
|
|
98
|
+
const options = {
|
|
99
|
+
name: "default",
|
|
100
|
+
random: false,
|
|
101
|
+
port: parseInt(process.env.PORT || "") || 3e3,
|
|
102
|
+
ports: [4e3, 5e3, 6e3, 7e3],
|
|
103
|
+
host: void 0,
|
|
104
|
+
memoName: "port",
|
|
105
|
+
...config
|
|
106
|
+
};
|
|
107
|
+
if (options.random) {
|
|
108
|
+
return getRandomPort(options.host);
|
|
109
|
+
}
|
|
110
|
+
const portsToCheck = [
|
|
111
|
+
options.port,
|
|
112
|
+
...options.ports
|
|
113
|
+
].filter(Boolean);
|
|
114
|
+
const memoOptions = { name: options.memoName, dir: options.memoDir };
|
|
115
|
+
const memoKey = "port_" + options.name;
|
|
116
|
+
const memo = await getMemo_1(memoOptions);
|
|
117
|
+
if (memo[memoKey]) {
|
|
118
|
+
portsToCheck.push(memo[memoKey]);
|
|
119
|
+
}
|
|
120
|
+
const availablePort = await findPort(portsToCheck, options.host);
|
|
121
|
+
await setMemo_1({ [memoKey]: availablePort }, memoOptions);
|
|
122
|
+
return availablePort;
|
|
123
|
+
}
|
|
124
|
+
async function getRandomPort(host) {
|
|
125
|
+
const port = await checkPort(0, host);
|
|
126
|
+
if (port === false) {
|
|
127
|
+
throw new Error("Unable to obtain an available random port number!");
|
|
128
|
+
}
|
|
129
|
+
return port;
|
|
130
|
+
}
|
|
131
|
+
async function checkPort(port, host = process.env.HOST) {
|
|
132
|
+
if (!host) {
|
|
133
|
+
host = getLocalHosts([void 0, "0.0.0.0"]);
|
|
134
|
+
}
|
|
135
|
+
if (!Array.isArray(host)) {
|
|
136
|
+
return _checkPort(port, host);
|
|
137
|
+
}
|
|
138
|
+
for (const _host of host) {
|
|
139
|
+
const _port = await _checkPort(port, _host);
|
|
140
|
+
if (_port === false) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
if (port === 0 && _port !== 0) {
|
|
144
|
+
port = _port;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return port;
|
|
148
|
+
}
|
|
149
|
+
function _checkPort(port, host) {
|
|
150
|
+
return new Promise((resolve) => {
|
|
151
|
+
const server = createServer();
|
|
152
|
+
server.unref();
|
|
153
|
+
server.on("error", (err) => {
|
|
154
|
+
if (err.code === "EINVAL" || err.code === "EADDRNOTAVAIL") {
|
|
155
|
+
resolve(port !== 0 ? port : false);
|
|
156
|
+
} else {
|
|
157
|
+
resolve(false);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
server.listen({ port, host }, () => {
|
|
161
|
+
const { port: port2 } = server.address();
|
|
162
|
+
server.close(() => {
|
|
163
|
+
resolve(port2);
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
function getLocalHosts(additional) {
|
|
169
|
+
const hosts = new Set(additional);
|
|
170
|
+
for (const _interface of Object.values(networkInterfaces())) {
|
|
171
|
+
for (const config of _interface) {
|
|
172
|
+
hosts.add(config.address);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return Array.from(hosts);
|
|
176
|
+
}
|
|
177
|
+
async function findPort(ports, host) {
|
|
178
|
+
for (const port of ports) {
|
|
179
|
+
const r = await checkPort(port, host);
|
|
180
|
+
if (r) {
|
|
181
|
+
return r;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return getRandomPort(host);
|
|
185
|
+
}
|
|
186
|
+
|
|
35
187
|
async function warmupViteServer(server, entries) {
|
|
36
188
|
const warmedUrls = /* @__PURE__ */ new Set();
|
|
37
189
|
const warmup = async (url) => {
|
|
@@ -50,6 +202,78 @@ async function warmupViteServer(server, entries) {
|
|
|
50
202
|
await Promise.all(entries.map((entry) => warmup(entry)));
|
|
51
203
|
}
|
|
52
204
|
|
|
205
|
+
const RelativeAssetPlugin = function() {
|
|
206
|
+
return {
|
|
207
|
+
name: "nuxt:vite-relative-asset",
|
|
208
|
+
generateBundle(_, bundle) {
|
|
209
|
+
const generatedAssets = Object.entries(bundle).filter(([_2, asset]) => asset.type === "asset").map(([key]) => escapeRE(key));
|
|
210
|
+
const assetRE = new RegExp(`\\/__NUXT_BASE__\\/(${generatedAssets.join("|")})`, "g");
|
|
211
|
+
for (const file in bundle) {
|
|
212
|
+
const asset = bundle[file];
|
|
213
|
+
if (asset.fileName.includes("legacy") && asset.type === "chunk" && asset.code.includes("innerHTML")) {
|
|
214
|
+
for (const delimiter of ["`", '"', "'"]) {
|
|
215
|
+
asset.code = asset.code.replace(new RegExp(`(?<=innerHTML=)${delimiter}([^${delimiter}]*)\\/__NUXT_BASE__\\/([^${delimiter}]*)${delimiter}`, "g"), "`$1${(window?.__NUXT__?.config.app.cdnURL || window?.__NUXT__?.config.app.baseURL) + window?.__NUXT__?.config.app.buildAssetsDir.slice(1)}$2`");
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (asset.type === "asset" && typeof asset.source === "string" && asset.fileName.endsWith(".css")) {
|
|
219
|
+
const depth = file.split("/").length - 1;
|
|
220
|
+
const assetBase = depth === 0 ? "." : Array.from({ length: depth }).map(() => "..").join("/");
|
|
221
|
+
const publicBase = Array.from({ length: depth + 1 }).map(() => "..").join("/");
|
|
222
|
+
asset.source = asset.source.replace(assetRE, (r) => r.replace(/\/__NUXT_BASE__/g, assetBase)).replace(/\/__NUXT_BASE__/g, publicBase);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
const VITE_ASSET_RE = /^export default ["'](__VITE_ASSET.*)["']$/;
|
|
229
|
+
const DynamicBasePlugin = createUnplugin(function(options = {}) {
|
|
230
|
+
return {
|
|
231
|
+
name: "nuxt:dynamic-base-path",
|
|
232
|
+
resolveId(id) {
|
|
233
|
+
if (id.startsWith("/__NUXT_BASE__")) {
|
|
234
|
+
return id.replace("/__NUXT_BASE__", "");
|
|
235
|
+
}
|
|
236
|
+
if (id === "#_config") {
|
|
237
|
+
return "#_config";
|
|
238
|
+
}
|
|
239
|
+
return null;
|
|
240
|
+
},
|
|
241
|
+
enforce: "post",
|
|
242
|
+
transform(code, id) {
|
|
243
|
+
const s = new MagicString(code);
|
|
244
|
+
if (options.globalPublicPath && id.includes("paths.mjs") && code.includes("const appConfig = ")) {
|
|
245
|
+
s.append(`${options.globalPublicPath} = buildAssetsURL();
|
|
246
|
+
`);
|
|
247
|
+
}
|
|
248
|
+
const assetId = code.match(VITE_ASSET_RE);
|
|
249
|
+
if (assetId) {
|
|
250
|
+
s.overwrite(0, code.length, [
|
|
251
|
+
"import { buildAssetsURL } from '#build/paths.mjs';",
|
|
252
|
+
`export default buildAssetsURL("${assetId[1]}".replace("/__NUXT_BASE__", ""));`
|
|
253
|
+
].join("\n"));
|
|
254
|
+
}
|
|
255
|
+
if (!id.includes("paths.mjs") && code.includes("NUXT_BASE") && !code.includes("import { publicAssetsURL as __publicAssetsURL }")) {
|
|
256
|
+
s.prepend("import { publicAssetsURL as __publicAssetsURL } from '#build/paths.mjs';\n");
|
|
257
|
+
}
|
|
258
|
+
if (id === "vite/preload-helper") {
|
|
259
|
+
s.prepend("import { buildAssetsDir } from '#build/paths.mjs';\n");
|
|
260
|
+
s.replace(/const base = ['"]\/__NUXT_BASE__\/['"]/, "const base = buildAssetsDir()");
|
|
261
|
+
}
|
|
262
|
+
s.replace(/from *['"]\/__NUXT_BASE__(\/[^'"]*)['"]/g, 'from "$1"');
|
|
263
|
+
for (const delimiter of ["`", "'", '"']) {
|
|
264
|
+
const delimiterRE = new RegExp(`(?<!(const base = |from *))${delimiter}([^${delimiter}]*)\\/__NUXT_BASE__\\/([^${delimiter}]*)${delimiter}`, "g");
|
|
265
|
+
s.replace(delimiterRE, (r) => "`" + r.replace(/\/__NUXT_BASE__\//g, "${__publicAssetsURL()}").slice(1, -1) + "`");
|
|
266
|
+
}
|
|
267
|
+
if (s.hasChanged()) {
|
|
268
|
+
return {
|
|
269
|
+
code: s.toString(),
|
|
270
|
+
map: s.generateMap({ source: id, includeContent: true })
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
});
|
|
276
|
+
|
|
53
277
|
function uniq(arr) {
|
|
54
278
|
return Array.from(new Set(arr));
|
|
55
279
|
}
|
|
@@ -106,33 +330,35 @@ function jsxPlugin() {
|
|
|
106
330
|
}
|
|
107
331
|
|
|
108
332
|
async function buildClient(ctx) {
|
|
109
|
-
const alias = {
|
|
333
|
+
const alias = {
|
|
334
|
+
"#_config": resolve(ctx.nuxt.options.buildDir, "config.client.mjs")
|
|
335
|
+
};
|
|
110
336
|
for (const p of ctx.builder.plugins) {
|
|
111
337
|
alias[p.name] = p.mode === "server" ? `defaultexport:${resolve(ctx.nuxt.options.buildDir, "empty.js")}` : `defaultexport:${p.src}`;
|
|
112
338
|
}
|
|
113
339
|
const clientConfig = vite.mergeConfig(ctx.config, {
|
|
114
340
|
define: {
|
|
115
|
-
"process.client":
|
|
116
|
-
"process.server":
|
|
117
|
-
"process.static":
|
|
118
|
-
"module.hot":
|
|
341
|
+
"process.client": true,
|
|
342
|
+
"process.server": false,
|
|
343
|
+
"process.static": false,
|
|
344
|
+
"module.hot": false
|
|
119
345
|
},
|
|
120
346
|
cacheDir: resolve(ctx.nuxt.options.rootDir, "node_modules/.cache/vite/client"),
|
|
121
347
|
resolve: {
|
|
122
348
|
alias
|
|
123
349
|
},
|
|
124
350
|
build: {
|
|
125
|
-
outDir: resolve(ctx.nuxt.options.buildDir, "dist/client"),
|
|
126
351
|
rollupOptions: {
|
|
127
352
|
input: resolve(ctx.nuxt.options.buildDir, "client.js")
|
|
128
353
|
},
|
|
129
354
|
manifest: true,
|
|
130
|
-
|
|
355
|
+
outDir: resolve(ctx.nuxt.options.buildDir, "dist/client")
|
|
131
356
|
},
|
|
132
357
|
plugins: [
|
|
133
358
|
jsxPlugin(),
|
|
134
359
|
createVuePlugin(ctx.config.vue),
|
|
135
360
|
PluginLegacy(),
|
|
361
|
+
RelativeAssetPlugin(),
|
|
136
362
|
devStyleSSRPlugin({
|
|
137
363
|
rootDir: ctx.nuxt.options.rootDir,
|
|
138
364
|
buildAssetsURL: joinURL(ctx.nuxt.options.app.baseURL, ctx.nuxt.options.app.buildAssetsDir)
|
|
@@ -154,10 +380,6 @@ async function buildClient(ctx) {
|
|
|
154
380
|
await ctx.nuxt.callHook("vite:serverCreated", viteServer);
|
|
155
381
|
const viteMiddleware = (req, res, next) => {
|
|
156
382
|
const originalURL = req.url;
|
|
157
|
-
req.url = req.url.replace("/_nuxt/", "/.nuxt/");
|
|
158
|
-
if (req.url.includes("@vite/client")) {
|
|
159
|
-
req.url = "/@vite/client";
|
|
160
|
-
}
|
|
161
383
|
viteServer.middlewares.handle(req, res, (err) => {
|
|
162
384
|
req.url = originalURL;
|
|
163
385
|
next(err);
|
|
@@ -382,19 +604,23 @@ async function generateBuildManifest(ctx) {
|
|
|
382
604
|
const initialJs = initialEntries.filter(isJS);
|
|
383
605
|
const initialAssets = initialEntries.filter(isCSS);
|
|
384
606
|
const polyfillName = initialEntries.find((id) => id.startsWith("polyfills-legacy."));
|
|
607
|
+
const polyfill = await fse.readFile(rDist("client/" + polyfillName), "utf-8");
|
|
385
608
|
const clientImports = initialJs.filter((id) => id !== polyfillName);
|
|
386
|
-
const clientEntryCode =
|
|
387
|
-
|
|
609
|
+
const clientEntryCode = [
|
|
610
|
+
polyfill,
|
|
611
|
+
"var appConfig = window?.__NUXT__?.config.app || {}",
|
|
612
|
+
'var publicBase = appConfig.cdnURL || ("." + appConfig.baseURL)',
|
|
613
|
+
`var imports = ${JSON.stringify(clientImports)};`,
|
|
614
|
+
"imports.reduce((p, id) => p.then(() => System.import(publicBase + appConfig.buildAssetsDir.slice(1) + id)), Promise.resolve())"
|
|
615
|
+
].join("\n");
|
|
388
616
|
const clientEntryName = "entry-legacy." + hash(clientEntryCode) + ".js";
|
|
389
617
|
const clientManifest = {
|
|
390
618
|
publicPath: ctx.nuxt.options.app.buildAssetsDir,
|
|
391
619
|
all: uniq([
|
|
392
|
-
polyfillName,
|
|
393
620
|
clientEntryName,
|
|
394
621
|
...clientEntries.flatMap(getModuleIds)
|
|
395
622
|
]).filter(Boolean),
|
|
396
623
|
initial: [
|
|
397
|
-
polyfillName,
|
|
398
624
|
clientEntryName,
|
|
399
625
|
...initialAssets
|
|
400
626
|
].filter(Boolean),
|
|
@@ -504,7 +730,10 @@ async function buildServer(ctx) {
|
|
|
504
730
|
"axios"
|
|
505
731
|
],
|
|
506
732
|
noExternal: [
|
|
733
|
+
/\/esm\/.*\.js$/,
|
|
507
734
|
/\.(es|esm|esm-browser|esm-bundler).js$/,
|
|
735
|
+
"#app",
|
|
736
|
+
/@nuxt\/nitro\/(dist|src)/,
|
|
508
737
|
...ctx.nuxt.options.build.transpile.filter((i) => typeof i === "string")
|
|
509
738
|
]
|
|
510
739
|
},
|
|
@@ -513,11 +742,13 @@ async function buildServer(ctx) {
|
|
|
513
742
|
ssr: ctx.nuxt.options.ssr ?? true,
|
|
514
743
|
ssrManifest: true,
|
|
515
744
|
rollupOptions: {
|
|
745
|
+
external: ["#_config"],
|
|
516
746
|
input: resolve(ctx.nuxt.options.buildDir, "server.js"),
|
|
517
747
|
output: {
|
|
518
|
-
format: "esm",
|
|
519
748
|
entryFileNames: "server.mjs",
|
|
520
|
-
chunkFileNames: "chunks/[name].mjs"
|
|
749
|
+
chunkFileNames: "chunks/[name].mjs",
|
|
750
|
+
preferConst: true,
|
|
751
|
+
format: "module"
|
|
521
752
|
},
|
|
522
753
|
onwarn(warning, rollupWarn) {
|
|
523
754
|
if (!["UNUSED_EXTERNAL_IMPORT"].includes(warning.code)) {
|
|
@@ -526,6 +757,9 @@ async function buildServer(ctx) {
|
|
|
526
757
|
}
|
|
527
758
|
}
|
|
528
759
|
},
|
|
760
|
+
server: {
|
|
761
|
+
preTransformRequests: false
|
|
762
|
+
},
|
|
529
763
|
plugins: [
|
|
530
764
|
jsxPlugin(),
|
|
531
765
|
vuePlugin
|
|
@@ -654,19 +888,38 @@ async function bundle(nuxt, builder) {
|
|
|
654
888
|
for (const p of builder.plugins) {
|
|
655
889
|
p.src = nuxt.resolver.resolvePath(resolve(nuxt.options.buildDir, p.src));
|
|
656
890
|
}
|
|
891
|
+
const hmrPortDefault = 24678;
|
|
892
|
+
const hmrPort = await getPort({
|
|
893
|
+
port: hmrPortDefault,
|
|
894
|
+
ports: Array.from({ length: 20 }, (_, i) => hmrPortDefault + 1 + i)
|
|
895
|
+
});
|
|
657
896
|
const ctx = {
|
|
658
897
|
nuxt,
|
|
659
898
|
builder,
|
|
660
899
|
config: vite.mergeConfig({
|
|
661
|
-
root: nuxt.options.
|
|
900
|
+
root: nuxt.options.srcDir,
|
|
662
901
|
mode: nuxt.options.dev ? "development" : "production",
|
|
663
902
|
logLevel: "warn",
|
|
903
|
+
base: nuxt.options.dev ? joinURL(nuxt.options.app.baseURL, nuxt.options.app.buildAssetsDir) : "/__NUXT_BASE__/",
|
|
904
|
+
publicDir: resolve(nuxt.options.rootDir, nuxt.options.srcDir, nuxt.options.dir.static),
|
|
905
|
+
vue: {
|
|
906
|
+
isProduction: !nuxt.options.dev,
|
|
907
|
+
template: {
|
|
908
|
+
compilerOptions: nuxt.options.vue.compilerOptions
|
|
909
|
+
}
|
|
910
|
+
},
|
|
911
|
+
esbuild: {
|
|
912
|
+
jsxFactory: "h",
|
|
913
|
+
jsxFragment: "Fragment",
|
|
914
|
+
tsconfigRaw: "{}"
|
|
915
|
+
},
|
|
916
|
+
clearScreen: false,
|
|
664
917
|
define: {
|
|
918
|
+
"process.dev": nuxt.options.dev,
|
|
665
919
|
"process.static": nuxt.options.target === "static",
|
|
666
920
|
"process.env.NODE_ENV": JSON.stringify(nuxt.options.dev ? "development" : "production"),
|
|
667
921
|
"process.mode": JSON.stringify(nuxt.options.dev ? "development" : "production"),
|
|
668
|
-
"process.target": JSON.stringify(nuxt.options.target)
|
|
669
|
-
"process.dev": nuxt.options.dev
|
|
922
|
+
"process.target": JSON.stringify(nuxt.options.target)
|
|
670
923
|
},
|
|
671
924
|
resolve: {
|
|
672
925
|
extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".vue"],
|
|
@@ -674,46 +927,57 @@ async function bundle(nuxt, builder) {
|
|
|
674
927
|
...nuxt.options.alias,
|
|
675
928
|
"#build": nuxt.options.buildDir,
|
|
676
929
|
".nuxt": nuxt.options.buildDir,
|
|
677
|
-
"
|
|
930
|
+
"/entry.mjs": resolve(nuxt.options.buildDir, "client.js"),
|
|
678
931
|
"web-streams-polyfill/ponyfill/es2018": resolve(distDir, "runtime/vite/mock/web-streams-polyfill.mjs"),
|
|
679
932
|
"whatwg-url": resolve(distDir, "runtime/vite/mock/whatwg-url.mjs"),
|
|
680
933
|
"abort-controller": resolve(distDir, "runtime/vite/mock/abort-controller.mjs")
|
|
681
934
|
}
|
|
682
935
|
},
|
|
683
|
-
vue: {},
|
|
684
|
-
server: {
|
|
685
|
-
fs: {
|
|
686
|
-
strict: false
|
|
687
|
-
}
|
|
688
|
-
},
|
|
689
|
-
css: resolveCSSOptions(nuxt),
|
|
690
936
|
optimizeDeps: {
|
|
691
937
|
exclude: [
|
|
938
|
+
...nuxt.options.build.transpile.filter((i) => typeof i === "string"),
|
|
939
|
+
"vue-demi",
|
|
692
940
|
"ufo",
|
|
693
941
|
"date-fns",
|
|
694
942
|
"nanoid",
|
|
695
943
|
"vue"
|
|
696
944
|
]
|
|
697
945
|
},
|
|
698
|
-
|
|
699
|
-
jsxFactory: "h",
|
|
700
|
-
jsxFragment: "Fragment",
|
|
701
|
-
tsconfigRaw: "{}"
|
|
702
|
-
},
|
|
703
|
-
publicDir: resolve(nuxt.options.srcDir, nuxt.options.dir.static),
|
|
704
|
-
clearScreen: false,
|
|
946
|
+
css: resolveCSSOptions(nuxt),
|
|
705
947
|
build: {
|
|
706
|
-
assetsDir: withoutLeadingSlash(nuxt.options.app.buildAssetsDir),
|
|
707
|
-
emptyOutDir: false
|
|
948
|
+
assetsDir: nuxt.options.dev ? withoutLeadingSlash(nuxt.options.app.buildAssetsDir) : ".",
|
|
949
|
+
emptyOutDir: false,
|
|
950
|
+
rollupOptions: {
|
|
951
|
+
output: { sanitizeFileName: sanitizeFilePath }
|
|
952
|
+
}
|
|
708
953
|
},
|
|
709
954
|
plugins: [
|
|
710
955
|
replace({
|
|
711
956
|
__webpack_public_path__: "globalThis.__webpack_public_path__"
|
|
712
957
|
}),
|
|
713
958
|
jsxPlugin(),
|
|
959
|
+
DynamicBasePlugin.vite(),
|
|
714
960
|
defaultExportPlugin()
|
|
715
|
-
]
|
|
716
|
-
|
|
961
|
+
],
|
|
962
|
+
server: {
|
|
963
|
+
watch: {
|
|
964
|
+
ignored: isIgnored
|
|
965
|
+
},
|
|
966
|
+
hmr: {
|
|
967
|
+
clientPort: hmrPort,
|
|
968
|
+
port: hmrPort
|
|
969
|
+
},
|
|
970
|
+
fs: {
|
|
971
|
+
strict: false,
|
|
972
|
+
allow: [
|
|
973
|
+
nuxt.options.buildDir,
|
|
974
|
+
nuxt.options.srcDir,
|
|
975
|
+
nuxt.options.rootDir,
|
|
976
|
+
...nuxt.options.modulesDir
|
|
977
|
+
]
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
}, nuxt.options.vite)
|
|
717
981
|
};
|
|
718
982
|
await ctx.nuxt.callHook("vite:extend", ctx);
|
|
719
983
|
if (nuxt.options.dev) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/bridge-edge",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-27480330.ade3378",
|
|
4
4
|
"repository": "nuxt/framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
|
|
22
22
|
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
|
|
23
23
|
"@babel/plugin-transform-typescript": "^7.16.8",
|
|
24
|
-
"@nuxt/kit": "npm:@nuxt/kit-edge@3.0.0-
|
|
25
|
-
"@nuxt/nitro": "npm:@nuxt/nitro-edge@3.0.0-
|
|
24
|
+
"@nuxt/kit": "npm:@nuxt/kit-edge@3.0.0-27480330.ade3378",
|
|
25
|
+
"@nuxt/nitro": "npm:@nuxt/nitro-edge@3.0.0-27480330.ade3378",
|
|
26
26
|
"@nuxt/postcss8": "^1.1.3",
|
|
27
|
-
"@nuxt/schema": "npm:@nuxt/schema-edge@3.0.0-
|
|
27
|
+
"@nuxt/schema": "npm:@nuxt/schema-edge@3.0.0-27480330.ade3378",
|
|
28
28
|
"@vitejs/plugin-legacy": "^1.8.0",
|
|
29
29
|
"@vue/composition-api": "^1.4.9",
|
|
30
30
|
"@vueuse/head": "^0.7.5",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"mlly": "^0.5.1",
|
|
46
46
|
"murmurhash-es": "^0.1.1",
|
|
47
47
|
"node-fetch": "^3.2.3",
|
|
48
|
-
"nuxi": "npm:nuxi-edge@3.0.0-
|
|
48
|
+
"nuxi": "npm:nuxi-edge@3.0.0-27480330.ade3378",
|
|
49
49
|
"ohash": "^0.1.0",
|
|
50
50
|
"pathe": "^0.2.0",
|
|
51
51
|
"perfect-debounce": "^0.1.3",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"ufo": "^0.8.3",
|
|
60
60
|
"unimport": "^0.1.3",
|
|
61
61
|
"unplugin": "^0.6.1",
|
|
62
|
-
"unplugin-vue2-script-setup": "^0.10.
|
|
62
|
+
"unplugin-vue2-script-setup": "^0.10.2",
|
|
63
63
|
"untyped": "^0.4.4",
|
|
64
64
|
"vite": "^2.9.1",
|
|
65
65
|
"vite-plugin-vue2": "^1.9.3",
|