nuxt-nightly 4.2.0-29333853.4751a6ac → 4.2.0-29334440.d083e066
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/index.mjs +149 -9
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -2538,7 +2538,7 @@ function findComponent(components, name, mode) {
|
|
|
2538
2538
|
return otherModeComponent;
|
|
2539
2539
|
}
|
|
2540
2540
|
|
|
2541
|
-
const SCRIPT_RE$
|
|
2541
|
+
const SCRIPT_RE$3 = /<script[^>]*>/i;
|
|
2542
2542
|
const SCRIPT_RE_GLOBAL = /<script[^>]*>/gi;
|
|
2543
2543
|
const HAS_SLOT_OR_CLIENT_RE = /<slot[^>]*>|nuxt-client/;
|
|
2544
2544
|
const TEMPLATE_RE$1 = /<template>[\s\S]*<\/template>/;
|
|
@@ -2581,7 +2581,7 @@ const IslandsTransformPlugin = (options) => createUnplugin((_options, meta) => {
|
|
|
2581
2581
|
}
|
|
2582
2582
|
const startingIndex = template.index || 0;
|
|
2583
2583
|
const s = new MagicString(code);
|
|
2584
|
-
if (!SCRIPT_RE$
|
|
2584
|
+
if (!SCRIPT_RE$3.test(code)) {
|
|
2585
2585
|
s.prepend("<script setup>" + IMPORT_CODE + "<\/script>");
|
|
2586
2586
|
} else {
|
|
2587
2587
|
s.replace(SCRIPT_RE_GLOBAL, (full) => {
|
|
@@ -3133,7 +3133,7 @@ const ComponentNamePlugin = (options) => createUnplugin(() => {
|
|
|
3133
3133
|
};
|
|
3134
3134
|
});
|
|
3135
3135
|
|
|
3136
|
-
const SCRIPT_RE$
|
|
3136
|
+
const SCRIPT_RE$2 = /(?<=<script[^>]*>)[\s\S]*?(?=<\/script>)/gi;
|
|
3137
3137
|
const TEMPLATE_RE = /<template>([\s\S]*)<\/template>/;
|
|
3138
3138
|
const hydrationStrategyMap = {
|
|
3139
3139
|
hydrateOnIdle: "Idle",
|
|
@@ -3173,7 +3173,7 @@ const LazyHydrationTransformPlugin = (options) => createUnplugin(() => {
|
|
|
3173
3173
|
try {
|
|
3174
3174
|
const ast = parse(template);
|
|
3175
3175
|
const scopeTracker = new ScopeTracker({ preserveExitedScopes: true });
|
|
3176
|
-
for (const { 0: script } of code.matchAll(SCRIPT_RE$
|
|
3176
|
+
for (const { 0: script } of code.matchAll(SCRIPT_RE$2)) {
|
|
3177
3177
|
if (!script) {
|
|
3178
3178
|
continue;
|
|
3179
3179
|
}
|
|
@@ -3832,7 +3832,7 @@ function addDeclarationTemplates(ctx, options) {
|
|
|
3832
3832
|
});
|
|
3833
3833
|
}
|
|
3834
3834
|
|
|
3835
|
-
const version = "4.2.0-
|
|
3835
|
+
const version = "4.2.0-29334440.d083e066";
|
|
3836
3836
|
|
|
3837
3837
|
const createImportProtectionPatterns = (nuxt, options) => {
|
|
3838
3838
|
const patterns = [];
|
|
@@ -5064,8 +5064,8 @@ const AsyncContextInjectionPlugin = (nuxt) => createUnplugin(() => {
|
|
|
5064
5064
|
|
|
5065
5065
|
const stringTypes = ["Literal", "TemplateLiteral"];
|
|
5066
5066
|
const NUXT_LIB_RE = /node_modules\/(?:nuxt|nuxt3|nuxt-nightly)\//;
|
|
5067
|
-
const SUPPORTED_EXT_RE = /\.(?:m?[jt]sx?|vue)/;
|
|
5068
|
-
const SCRIPT_RE = /(?<=<script[^>]*>)[\s\S]*?(?=<\/script>)/i;
|
|
5067
|
+
const SUPPORTED_EXT_RE$1 = /\.(?:m?[jt]sx?|vue)/;
|
|
5068
|
+
const SCRIPT_RE$1 = /(?<=<script[^>]*>)[\s\S]*?(?=<\/script>)/i;
|
|
5069
5069
|
const ComposableKeysPlugin = (options) => createUnplugin(() => {
|
|
5070
5070
|
const composableMeta = {};
|
|
5071
5071
|
const composableLengths = /* @__PURE__ */ new Set();
|
|
@@ -5082,14 +5082,14 @@ const ComposableKeysPlugin = (options) => createUnplugin(() => {
|
|
|
5082
5082
|
enforce: "post",
|
|
5083
5083
|
transformInclude(id) {
|
|
5084
5084
|
const { pathname, search } = parseURL(decodeURIComponent(pathToFileURL(id).href));
|
|
5085
|
-
return !NUXT_LIB_RE.test(pathname) && SUPPORTED_EXT_RE.test(pathname) && parseQuery(search).type !== "style" && !parseQuery(search).macro;
|
|
5085
|
+
return !NUXT_LIB_RE.test(pathname) && SUPPORTED_EXT_RE$1.test(pathname) && parseQuery(search).type !== "style" && !parseQuery(search).macro;
|
|
5086
5086
|
},
|
|
5087
5087
|
transform: {
|
|
5088
5088
|
filter: {
|
|
5089
5089
|
code: { include: KEYED_FUNCTIONS_RE }
|
|
5090
5090
|
},
|
|
5091
5091
|
handler(code, id) {
|
|
5092
|
-
const { 0: script = code, index: codeIndex = 0 } = code.match(SCRIPT_RE) || { index: 0, 0: code };
|
|
5092
|
+
const { 0: script = code, index: codeIndex = 0 } = code.match(SCRIPT_RE$1) || { index: 0, 0: code };
|
|
5093
5093
|
const s = new MagicString(code);
|
|
5094
5094
|
let imports;
|
|
5095
5095
|
let count = 0;
|
|
@@ -5382,6 +5382,140 @@ function PrehydrateTransformPlugin(options = {}) {
|
|
|
5382
5382
|
}));
|
|
5383
5383
|
}
|
|
5384
5384
|
|
|
5385
|
+
const functionsToExtract = /* @__PURE__ */ new Set(["useAsyncData", "useLazyAsyncData"]);
|
|
5386
|
+
const FUNCTIONS_RE = /\buse(?:Lazy)?AsyncData\b/;
|
|
5387
|
+
const SUPPORTED_EXT_RE = /\.(?:m?[jt]sx?|vue)$/;
|
|
5388
|
+
const SCRIPT_RE = /(?<=<script[^>]*>)[\s\S]*?(?=<\/script>)/i;
|
|
5389
|
+
const ExtractAsyncDataHandlersPlugin = (options) => createUnplugin(() => {
|
|
5390
|
+
const asyncDatas = {};
|
|
5391
|
+
let count = 0;
|
|
5392
|
+
return {
|
|
5393
|
+
name: "nuxt:extract-async-data-handlers",
|
|
5394
|
+
enforce: "post",
|
|
5395
|
+
resolveId(source) {
|
|
5396
|
+
if (source in asyncDatas) {
|
|
5397
|
+
return source;
|
|
5398
|
+
}
|
|
5399
|
+
},
|
|
5400
|
+
load(id) {
|
|
5401
|
+
if (id in asyncDatas) {
|
|
5402
|
+
return asyncDatas[id];
|
|
5403
|
+
}
|
|
5404
|
+
},
|
|
5405
|
+
transformInclude(id) {
|
|
5406
|
+
const { pathname, search } = parseURL(decodeURIComponent(pathToFileURL(id).href));
|
|
5407
|
+
return SUPPORTED_EXT_RE.test(pathname) && parseQuery(search).type !== "style" && !parseQuery(search).macro;
|
|
5408
|
+
},
|
|
5409
|
+
transform: {
|
|
5410
|
+
filter: {
|
|
5411
|
+
id: {
|
|
5412
|
+
exclude: [/nuxt\/(src|dist)\/app/]
|
|
5413
|
+
},
|
|
5414
|
+
code: { include: FUNCTIONS_RE }
|
|
5415
|
+
},
|
|
5416
|
+
handler(code, id) {
|
|
5417
|
+
const { 0: script = code, index: codeIndex = 0 } = code.match(SCRIPT_RE) || { index: 0, 0: code };
|
|
5418
|
+
let s;
|
|
5419
|
+
const scopeTracker = new ScopeTracker({ preserveExitedScopes: true });
|
|
5420
|
+
const parseResult = parseAndWalk(script, id, { scopeTracker });
|
|
5421
|
+
scopeTracker.freeze();
|
|
5422
|
+
walk(parseResult.program, {
|
|
5423
|
+
scopeTracker,
|
|
5424
|
+
enter(node) {
|
|
5425
|
+
if (node.type !== "CallExpression" || node.callee.type !== "Identifier" || !functionsToExtract.has(node.callee.name)) {
|
|
5426
|
+
return;
|
|
5427
|
+
}
|
|
5428
|
+
const callExpression = node;
|
|
5429
|
+
const fetcherFunction = callExpression.arguments.find((fn) => fn.type === "ArrowFunctionExpression" || fn.type === "FunctionExpression");
|
|
5430
|
+
if (!fetcherFunction || fetcherFunction.type !== "ArrowFunctionExpression" && fetcherFunction.type !== "FunctionExpression" || !fetcherFunction.body) {
|
|
5431
|
+
return;
|
|
5432
|
+
}
|
|
5433
|
+
s ||= new MagicString(code);
|
|
5434
|
+
const referencedVariables = /* @__PURE__ */ new Set();
|
|
5435
|
+
const imports = /* @__PURE__ */ new Set();
|
|
5436
|
+
walk(fetcherFunction.body, {
|
|
5437
|
+
scopeTracker,
|
|
5438
|
+
enter(innerNode, parent) {
|
|
5439
|
+
if (innerNode.type !== "Identifier") {
|
|
5440
|
+
return;
|
|
5441
|
+
}
|
|
5442
|
+
if (parent) {
|
|
5443
|
+
if (parent.type === "MemberExpression" && parent.property === innerNode && parent.computed === false) {
|
|
5444
|
+
return;
|
|
5445
|
+
}
|
|
5446
|
+
if (parent.type === "Property" && parent.key === innerNode && parent.computed === false) {
|
|
5447
|
+
return;
|
|
5448
|
+
}
|
|
5449
|
+
if (parent.type === "MethodDefinition" && parent.key === innerNode && parent.computed === false) {
|
|
5450
|
+
return;
|
|
5451
|
+
}
|
|
5452
|
+
if (parent.type === "PropertyDefinition" && parent.key === innerNode && parent.computed === false) {
|
|
5453
|
+
return;
|
|
5454
|
+
}
|
|
5455
|
+
}
|
|
5456
|
+
const declaration = scopeTracker.getDeclaration(innerNode.name);
|
|
5457
|
+
if (!declaration) {
|
|
5458
|
+
return;
|
|
5459
|
+
}
|
|
5460
|
+
if (declaration.type === "Import") {
|
|
5461
|
+
imports.add(innerNode.name);
|
|
5462
|
+
} else if (declaration.type !== "FunctionParam") {
|
|
5463
|
+
const functionBodyStart = fetcherFunction.body.start;
|
|
5464
|
+
const functionBodyEnd = fetcherFunction.body.end;
|
|
5465
|
+
if (declaration.start < functionBodyStart || declaration.end > functionBodyEnd) {
|
|
5466
|
+
referencedVariables.add(innerNode.name);
|
|
5467
|
+
}
|
|
5468
|
+
}
|
|
5469
|
+
}
|
|
5470
|
+
});
|
|
5471
|
+
const importStatements = /* @__PURE__ */ new Set();
|
|
5472
|
+
walk(parseResult.program, {
|
|
5473
|
+
enter(importDecl) {
|
|
5474
|
+
if (importDecl.type !== "ImportDeclaration") {
|
|
5475
|
+
return;
|
|
5476
|
+
}
|
|
5477
|
+
if (importDecl.specifiers?.some((spec) => spec.local && imports.has(spec.local.name))) {
|
|
5478
|
+
importStatements.add(script.slice(importDecl.start, importDecl.end));
|
|
5479
|
+
}
|
|
5480
|
+
}
|
|
5481
|
+
});
|
|
5482
|
+
const imps = Array.from(importStatements).join("\n");
|
|
5483
|
+
const key = `${dirname(id)}/async-data-chunk-${count++}.js`;
|
|
5484
|
+
const isBlockStatement = fetcherFunction.body.type === "BlockStatement";
|
|
5485
|
+
const startOffset = codeIndex + fetcherFunction.body.start;
|
|
5486
|
+
const endOffset = codeIndex + fetcherFunction.body.end;
|
|
5487
|
+
const chunk = s.clone();
|
|
5488
|
+
const parameters = [...referencedVariables].join(", ");
|
|
5489
|
+
const returnPrefix = isBlockStatement ? "" : "return ";
|
|
5490
|
+
const preface = `${imps}
|
|
5491
|
+
export default async function (${parameters}) { ${returnPrefix}`;
|
|
5492
|
+
const suffix = ` }`;
|
|
5493
|
+
if (isBlockStatement) {
|
|
5494
|
+
chunk.overwrite(0, startOffset + 1, preface);
|
|
5495
|
+
chunk.overwrite(endOffset - 1, code.length, suffix);
|
|
5496
|
+
} else {
|
|
5497
|
+
chunk.overwrite(0, startOffset, preface);
|
|
5498
|
+
chunk.overwrite(endOffset, code.length, suffix);
|
|
5499
|
+
}
|
|
5500
|
+
asyncDatas[key] = {
|
|
5501
|
+
code: chunk.toString(),
|
|
5502
|
+
map: options.sourcemap ? chunk.generateMap({ hires: true }) : void 0
|
|
5503
|
+
};
|
|
5504
|
+
const importCall = `() => import('${key}').then(r => (r.default || r)(${parameters}))`;
|
|
5505
|
+
s.overwrite(codeIndex + fetcherFunction.start, codeIndex + fetcherFunction.end, importCall);
|
|
5506
|
+
}
|
|
5507
|
+
});
|
|
5508
|
+
if (s?.hasChanged()) {
|
|
5509
|
+
return {
|
|
5510
|
+
code: s.toString(),
|
|
5511
|
+
map: options.sourcemap ? s.generateMap({ hires: true }) : void 0
|
|
5512
|
+
};
|
|
5513
|
+
}
|
|
5514
|
+
}
|
|
5515
|
+
}
|
|
5516
|
+
};
|
|
5517
|
+
});
|
|
5518
|
+
|
|
5385
5519
|
const PREFIX = "virtual:nuxt:";
|
|
5386
5520
|
const PREFIX_RE = /^\/?virtual:nuxt:/;
|
|
5387
5521
|
const RELATIVE_ID_RE = /^\.{1,2}[\\/]/;
|
|
@@ -5710,6 +5844,12 @@ Using \`${fallbackCompatibilityDate}\` as fallback. More info at: ${colors.under
|
|
|
5710
5844
|
addBuildPlugin(DevOnlyPlugin({
|
|
5711
5845
|
sourcemap: !!nuxt.options.sourcemap.server || !!nuxt.options.sourcemap.client
|
|
5712
5846
|
}));
|
|
5847
|
+
if (nuxt.options.experimental.extractAsyncDataHandlers) {
|
|
5848
|
+
addBuildPlugin(ExtractAsyncDataHandlersPlugin({
|
|
5849
|
+
sourcemap: !!nuxt.options.sourcemap.client,
|
|
5850
|
+
rootDir: nuxt.options.rootDir
|
|
5851
|
+
}), { server: false });
|
|
5852
|
+
}
|
|
5713
5853
|
}
|
|
5714
5854
|
if (nuxt.options.dev) {
|
|
5715
5855
|
addPlugin(resolve(nuxt.options.appDir, "plugins/check-if-layout-used"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-nightly",
|
|
3
|
-
"version": "4.2.0-
|
|
3
|
+
"version": "4.2.0-29334440.d083e066",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/nuxt/nuxt.git",
|
|
@@ -68,10 +68,10 @@
|
|
|
68
68
|
"@nuxt/cli": "npm:@nuxt/cli-nightly@latest",
|
|
69
69
|
"@nuxt/devalue": "^2.0.2",
|
|
70
70
|
"@nuxt/devtools": "^2.6.5",
|
|
71
|
-
"@nuxt/kit": "npm:@nuxt/kit-nightly@4.2.0-
|
|
72
|
-
"@nuxt/schema": "npm:@nuxt/schema-nightly@4.2.0-
|
|
71
|
+
"@nuxt/kit": "npm:@nuxt/kit-nightly@4.2.0-29334440.d083e066",
|
|
72
|
+
"@nuxt/schema": "npm:@nuxt/schema-nightly@4.2.0-29334440.d083e066",
|
|
73
73
|
"@nuxt/telemetry": "^2.6.6",
|
|
74
|
-
"@nuxt/vite-builder": "npm:@nuxt/vite-builder-nightly@4.2.0-
|
|
74
|
+
"@nuxt/vite-builder": "npm:@nuxt/vite-builder-nightly@4.2.0-29334440.d083e066",
|
|
75
75
|
"@unhead/vue": "^2.0.14",
|
|
76
76
|
"@vue/shared": "^3.5.22",
|
|
77
77
|
"c12": "^3.3.0",
|