@mochi-css/next 3.0.0 → 4.0.0

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.js CHANGED
@@ -48,7 +48,7 @@ async function startCssWatcher(tmpDir) {
48
48
  if (watcherStarted) return;
49
49
  watcherStarted = true;
50
50
  const cwd = process.cwd();
51
- const resolved = await (0, __mochi_css_config.resolveConfig)(await (0, __mochi_css_config.loadConfig)(), void 0, { extractors: __mochi_css_builder.defaultExtractors });
51
+ const resolved = await (0, __mochi_css_config.resolveConfig)(await (0, __mochi_css_config.loadConfig)(), void 0, {});
52
52
  const effectiveTmpDir = resolved.tmpDir ? path.default.resolve(cwd, resolved.tmpDir) : tmpDir;
53
53
  const debug = resolved.debug ?? false;
54
54
  const absoluteRoots = resolved.roots.map((root) => typeof root === "string" ? path.default.resolve(cwd, root) : {
@@ -60,16 +60,20 @@ async function startCssWatcher(tmpDir) {
60
60
  console.warn("[mochi-css] watcher: no roots configured — add `roots` to mochi.config.ts");
61
61
  return;
62
62
  }
63
- const context = new __mochi_css_config.FullContext();
63
+ const context = new __mochi_css_config.FullContext(resolved.onDiagnostic ?? (() => {}));
64
64
  for (const plugin of resolved.plugins) plugin.onLoad?.(context);
65
65
  const builder = new __mochi_css_builder.Builder({
66
66
  roots: absoluteRoots,
67
- extractors: resolved.extractors,
67
+ stages: [...context.stages.getAll()],
68
68
  bundler: new __mochi_css_builder.RolldownBundler(),
69
69
  runner: new __mochi_css_builder.VmRunner(),
70
70
  splitCss: resolved.splitCss,
71
- filePreProcess: ({ content, filePath }) => context.sourceTransform.transform(content, { filePath }),
72
- astPostProcessors: context.getAnalysisHooks()
71
+ filePreProcess: ({ content, filePath }) => context.filePreProcess.transform(content, { filePath }),
72
+ sourceTransforms: [...context.sourceTransforms.getAll()],
73
+ emitHooks: [...context.emitHooks.getAll()],
74
+ cleanup: () => {
75
+ context.cleanup.runAll();
76
+ }
73
77
  });
74
78
  let rebuildTimer;
75
79
  let rebuildGuard = Promise.resolve();
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { createRequire } from "node:module";
2
2
  import path from "path";
3
3
  import fs from "fs";
4
4
  import { FullContext, loadConfig, resolveConfig } from "@mochi-css/config";
5
- import { Builder, RolldownBundler, VmRunner, defaultExtractors, fileHash } from "@mochi-css/builder";
5
+ import { Builder, RolldownBundler, VmRunner, fileHash } from "@mochi-css/builder";
6
6
 
7
7
  //#region rolldown:runtime
8
8
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
@@ -48,7 +48,7 @@ async function startCssWatcher(tmpDir) {
48
48
  if (watcherStarted) return;
49
49
  watcherStarted = true;
50
50
  const cwd = process.cwd();
51
- const resolved = await resolveConfig(await loadConfig(), void 0, { extractors: defaultExtractors });
51
+ const resolved = await resolveConfig(await loadConfig(), void 0, {});
52
52
  const effectiveTmpDir = resolved.tmpDir ? path.resolve(cwd, resolved.tmpDir) : tmpDir;
53
53
  const debug = resolved.debug ?? false;
54
54
  const absoluteRoots = resolved.roots.map((root) => typeof root === "string" ? path.resolve(cwd, root) : {
@@ -60,16 +60,20 @@ async function startCssWatcher(tmpDir) {
60
60
  console.warn("[mochi-css] watcher: no roots configured — add `roots` to mochi.config.ts");
61
61
  return;
62
62
  }
63
- const context = new FullContext();
63
+ const context = new FullContext(resolved.onDiagnostic ?? (() => {}));
64
64
  for (const plugin of resolved.plugins) plugin.onLoad?.(context);
65
65
  const builder = new Builder({
66
66
  roots: absoluteRoots,
67
- extractors: resolved.extractors,
67
+ stages: [...context.stages.getAll()],
68
68
  bundler: new RolldownBundler(),
69
69
  runner: new VmRunner(),
70
70
  splitCss: resolved.splitCss,
71
- filePreProcess: ({ content, filePath }) => context.sourceTransform.transform(content, { filePath }),
72
- astPostProcessors: context.getAnalysisHooks()
71
+ filePreProcess: ({ content, filePath }) => context.filePreProcess.transform(content, { filePath }),
72
+ sourceTransforms: [...context.sourceTransforms.getAll()],
73
+ emitHooks: [...context.emitHooks.getAll()],
74
+ cleanup: () => {
75
+ context.cleanup.runAll();
76
+ }
73
77
  });
74
78
  let rebuildTimer;
75
79
  let rebuildGuard = Promise.resolve();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mochi-css/next",
3
3
  "repository": "git@github.com:Niikelion/mochi-css.git",
4
- "version": "3.0.0",
4
+ "version": "4.0.0",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -37,9 +37,11 @@
37
37
  "coverage": "vitest run --coverage"
38
38
  },
39
39
  "dependencies": {
40
- "@mochi-css/builder": "^3.0.0",
41
- "@mochi-css/config": "^3.0.0",
42
- "diff": "^8.0.3",
40
+ "@mochi-css/builder": "^4.0.0",
41
+ "@mochi-css/config": "^4.0.0",
42
+ "diff": "^8.0.3"
43
+ },
44
+ "peerDependencies": {
43
45
  "next": "^14 || ^15 || ^16"
44
46
  },
45
47
  "devDependencies": {
@@ -47,6 +49,9 @@
47
49
  "@mochi-css/test": "^2.0.0",
48
50
  "@types/diff": "^8.0.0",
49
51
  "@types/node": "^24.8.1",
52
+ "next": "^16",
53
+ "react": "^19",
54
+ "react-dom": "^19",
50
55
  "typescript": "^5.9.3",
51
56
  "vitest": "^4.0.15"
52
57
  }