@nuxt/vite-builder-nightly 4.1.3-29310473.a57f7fb7 → 4.1.3-29312995.d3ce79f3

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 +25 -7
  2. package/package.json +10 -3
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import * as vite from 'vite';
3
3
  import { isCSSRequest, createLogger } from 'vite';
4
4
  import { dirname, normalize, resolve, join, relative, basename, isAbsolute } from 'pathe';
5
5
  import { useNitro, logger, useNuxt, resolvePath, getLayerDirectories, createIsIgnored, addVitePlugin } from '@nuxt/kit';
6
- import replace from '@rollup/plugin-replace';
6
+ import replacePlugin from '@rollup/plugin-replace';
7
7
  import { findStaticImports, sanitizeFilePath } from 'mlly';
8
8
  import { parseURL, parseQuery, joinURL, getQuery, withLeadingSlash, withTrailingSlash, withoutLeadingSlash, withoutBase } from 'ufo';
9
9
  import { filename as filename$1 } from 'pathe/utils';
@@ -28,7 +28,7 @@ import { colorize } from 'consola/utils';
28
28
  import escapeStringRegexp from 'escape-string-regexp';
29
29
  import { isBuiltin } from 'node:module';
30
30
  import { createJiti } from 'jiti';
31
- import { genImport, genObjectFromRawEntries } from 'knitwork';
31
+ import { genImport, genArrayFromRaw, genObjectFromRawEntries } from 'knitwork';
32
32
 
33
33
  function isVue(id, opts = {}) {
34
34
  const { search } = parseURL(decodeURIComponent(pathToFileURL(id).href));
@@ -1501,12 +1501,26 @@ function SSRStylesPlugin(options) {
1501
1501
  source: ""
1502
1502
  });
1503
1503
  const baseDir = dirname(base);
1504
+ const cssImports = /* @__PURE__ */ new Set();
1505
+ const exportNames = /* @__PURE__ */ new Set();
1506
+ const importStatements = /* @__PURE__ */ new Set();
1507
+ let i = 0;
1508
+ for (const css of files) {
1509
+ const file2 = this.getFileName(css);
1510
+ if (cssImports.has(file2)) {
1511
+ continue;
1512
+ }
1513
+ cssImports.add(file2);
1514
+ const name = `style_${i++}`;
1515
+ importStatements.add(genImport(`./${relative(baseDir, file2)}`, name));
1516
+ exportNames.add(name);
1517
+ }
1504
1518
  emitted[file] = this.emitFile({
1505
1519
  type: "asset",
1506
1520
  name: `${fileName}-styles.mjs`,
1507
1521
  source: [
1508
- ...files.map((css, i) => `import style_${i} from './${relative(baseDir, this.getFileName(css))}';`),
1509
- `export default [${files.map((_, i) => `style_${i}`).join(", ")}]`
1522
+ ...importStatements,
1523
+ `export default ${genArrayFromRaw([...exportNames])}`
1510
1524
  ].join("\n")
1511
1525
  });
1512
1526
  }
@@ -1819,15 +1833,19 @@ const bundle = async (nuxt) => {
1819
1833
  }), { server: nuxt.options.ssr });
1820
1834
  }
1821
1835
  await nuxt.callHook("vite:extend", ctx);
1822
- nuxt.hook("vite:extendConfig", (config) => {
1836
+ nuxt.hook("vite:extendConfig", async (config) => {
1823
1837
  const replaceOptions = /* @__PURE__ */ Object.create(null);
1824
- replaceOptions.preventAssignment = true;
1825
1838
  for (const key in config.define) {
1826
1839
  if (key.startsWith("import.meta.")) {
1827
1840
  replaceOptions[key] = config.define[key];
1828
1841
  }
1829
1842
  }
1830
- config.plugins.push(replace(replaceOptions));
1843
+ if (vite.rolldownVersion) {
1844
+ const { replacePlugin: replacePlugin2 } = await import('rolldown/experimental');
1845
+ config.plugins.push(replacePlugin2(replaceOptions));
1846
+ } else {
1847
+ config.plugins.push(replacePlugin({ ...replaceOptions, preventAssignment: true }));
1848
+ }
1831
1849
  });
1832
1850
  if (!nuxt.options.dev) {
1833
1851
  const chunksWithInlinedCSS = /* @__PURE__ */ new Set();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/vite-builder-nightly",
3
- "version": "4.1.3-29310473.a57f7fb7",
3
+ "version": "4.1.3-29312995.d3ce79f3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -21,14 +21,15 @@
21
21
  "dist"
22
22
  ],
23
23
  "devDependencies": {
24
- "@nuxt/schema": "npm:@nuxt/schema-nightly@4.1.3-29310473.a57f7fb7",
24
+ "@nuxt/schema": "npm:@nuxt/schema-nightly@4.1.3-29312995.d3ce79f3",
25
25
  "nitropack": "2.12.6",
26
+ "rolldown": "1.0.0-beta.38",
26
27
  "rollup": "4.50.2",
27
28
  "unbuild": "3.6.1",
28
29
  "vue": "3.5.21"
29
30
  },
30
31
  "dependencies": {
31
- "@nuxt/kit": "npm:@nuxt/kit-nightly@4.1.3-29310473.a57f7fb7",
32
+ "@nuxt/kit": "npm:@nuxt/kit-nightly@4.1.3-29312995.d3ce79f3",
32
33
  "@rollup/plugin-replace": "^6.0.2",
33
34
  "@vitejs/plugin-vue": "^6.0.1",
34
35
  "@vitejs/plugin-vue-jsx": "^5.1.1",
@@ -59,8 +60,14 @@
59
60
  "vue-bundle-renderer": "^2.1.2"
60
61
  },
61
62
  "peerDependencies": {
63
+ "rolldown": "^1.0.0-beta.38",
62
64
  "vue": "^3.3.4"
63
65
  },
66
+ "peerDependenciesMeta": {
67
+ "rolldown": {
68
+ "optional": true
69
+ }
70
+ },
64
71
  "engines": {
65
72
  "node": "^20.19.0 || >=22.12.0"
66
73
  },