@nuxt/vite-builder-nightly 4.4.0-29544347.e1dade21 → 4.4.0-29544389.d497aa6f

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 (2) hide show
  1. package/dist/index.mjs +32 -14
  2. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -1507,13 +1507,22 @@ function SSRStylesPlugin(nuxt) {
1507
1507
  if (!chunk) continue;
1508
1508
  if (chunk.isEntry && chunk.src) entryIds.add(chunk.src);
1509
1509
  else chunk.css &&= [];
1510
+ if (chunk.imports && chunk.src) {
1511
+ const componentBaseName = filename(chunk.src);
1512
+ for (const imp of chunk.imports) {
1513
+ const imported = manifest[imp];
1514
+ if (imported?.css?.length && !imported.isEntry && !imported.src) {
1515
+ if (imported.css.every((css) => css.startsWith(componentBaseName + "."))) imported.css = [];
1516
+ }
1517
+ }
1518
+ }
1510
1519
  }
1511
1520
  nitro.options.virtual["#internal/nuxt/entry-ids.mjs"] = () => `export default ${JSON.stringify(Array.from(entryIds))}`;
1512
1521
  nitro.options._config.virtual ||= {};
1513
1522
  nitro.options._config.virtual["#internal/nuxt/entry-ids.mjs"] = nitro.options.virtual["#internal/nuxt/entry-ids.mjs"];
1514
1523
  });
1515
1524
  const cssMap = {};
1516
- const idRefMap = {};
1525
+ const emittedFileRefs = {};
1517
1526
  const options = {
1518
1527
  shouldInline: nuxt.options.features.inlineStyles,
1519
1528
  globalCSS: nuxt.options.css
@@ -1678,12 +1687,16 @@ function SSRStylesPlugin(nuxt) {
1678
1687
  continue;
1679
1688
  }
1680
1689
  emittedIds.add(file);
1681
- const ref = this.emitFile({
1682
- type: "chunk",
1683
- name: `${idFilename}-styles-${++styleCtr}.mjs`,
1684
- id: fileInline
1685
- });
1686
- idRefMap[relativeToSrcDir(file)] = ref;
1690
+ const resolvedInlineId = res.id;
1691
+ let ref = emittedFileRefs[resolvedInlineId];
1692
+ if (!ref) {
1693
+ ref = this.emitFile({
1694
+ type: "chunk",
1695
+ name: `${idFilename}-styles-${++styleCtr}.mjs`,
1696
+ id: fileInline
1697
+ });
1698
+ emittedFileRefs[resolvedInlineId] = ref;
1699
+ }
1687
1700
  idMap.files.push(ref);
1688
1701
  }
1689
1702
  if (!SUPPORTED_FILES_RE.test(pathname)) return;
@@ -1692,7 +1705,8 @@ function SSRStylesPlugin(nuxt) {
1692
1705
  const resolved = await this.resolve(i.specifier, id);
1693
1706
  if (!resolved) continue;
1694
1707
  const resolvedIdInline = resolved.id + "?inline&used";
1695
- if (!await this.resolve(resolvedIdInline)) {
1708
+ const res = await this.resolve(resolvedIdInline);
1709
+ if (!res) {
1696
1710
  if (!warnCache.has(resolved.id)) {
1697
1711
  warnCache.add(resolved.id);
1698
1712
  this.warn(`[nuxt] Cannot extract styles for \`${i.specifier}\`. Its styles will not be inlined when server-rendering.`);
@@ -1700,12 +1714,16 @@ function SSRStylesPlugin(nuxt) {
1700
1714
  continue;
1701
1715
  }
1702
1716
  if (emittedIds.has(resolved.id)) continue;
1703
- const ref = this.emitFile({
1704
- type: "chunk",
1705
- name: `${idFilename}-styles-${++styleCtr}.mjs`,
1706
- id: resolvedIdInline
1707
- });
1708
- idRefMap[relativeToSrcDir(resolved.id)] = ref;
1717
+ const resolvedInlineId = res.id;
1718
+ let ref = emittedFileRefs[resolvedInlineId];
1719
+ if (!ref) {
1720
+ ref = this.emitFile({
1721
+ type: "chunk",
1722
+ name: `${idFilename}-styles-${++styleCtr}.mjs`,
1723
+ id: resolvedIdInline
1724
+ });
1725
+ emittedFileRefs[resolvedInlineId] = ref;
1726
+ }
1709
1727
  idMap.files.push(ref);
1710
1728
  }
1711
1729
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/vite-builder-nightly",
3
- "version": "4.4.0-29544347.e1dade21",
3
+ "version": "4.4.0-29544389.d497aa6f",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -22,7 +22,7 @@
22
22
  "dist"
23
23
  ],
24
24
  "devDependencies": {
25
- "@nuxt/schema": "npm:@nuxt/schema-nightly@4.4.0-29544347.e1dade21",
25
+ "@nuxt/schema": "npm:@nuxt/schema-nightly@4.4.0-29544389.d497aa6f",
26
26
  "h3": "1.15.5",
27
27
  "h3-next": "npm:h3@2.0.1-rc.14",
28
28
  "nitropack": "2.13.1",
@@ -32,7 +32,7 @@
32
32
  "vue": "3.5.29"
33
33
  },
34
34
  "dependencies": {
35
- "@nuxt/kit": "npm:@nuxt/kit-nightly@4.4.0-29544347.e1dade21",
35
+ "@nuxt/kit": "npm:@nuxt/kit-nightly@4.4.0-29544389.d497aa6f",
36
36
  "@rollup/plugin-replace": "^6.0.3",
37
37
  "@vitejs/plugin-vue": "^6.0.4",
38
38
  "@vitejs/plugin-vue-jsx": "^5.1.4",
@@ -63,7 +63,7 @@
63
63
  "vue-bundle-renderer": "^2.2.0"
64
64
  },
65
65
  "peerDependencies": {
66
- "nuxt": "npm:nuxt-nightly@4.4.0-29544347.e1dade21",
66
+ "nuxt": "npm:nuxt-nightly@4.4.0-29544389.d497aa6f",
67
67
  "rolldown": "^1.0.0-beta.38",
68
68
  "vue": "^3.3.4"
69
69
  },