@mochi-css/next 4.0.2 → 6.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
@@ -45,23 +45,6 @@ function resolveAbsoluteRoots(cwd, roots) {
45
45
  path: __mochi_css_builder.path.resolve(posixCwd, root.path)
46
46
  });
47
47
  }
48
- function createBuilder(resolved, roots) {
49
- const context = new __mochi_css_config.FullContext(resolved.onDiagnostic ?? (() => {}));
50
- for (const plugin of resolved.plugins) plugin.onLoad?.(context);
51
- return new __mochi_css_builder.Builder({
52
- roots,
53
- stages: [...context.stages.getAll()],
54
- bundler: new __mochi_css_builder.RolldownBundler(),
55
- runner: new __mochi_css_builder.VmRunner(),
56
- splitCss: resolved.splitCss,
57
- filePreProcess: ({ content, filePath }) => context.filePreProcess.transform(content, { filePath }),
58
- sourceTransforms: [...context.sourceTransforms.getAll()],
59
- emitHooks: [...context.emitHooks.getAll()],
60
- cleanup: () => {
61
- context.cleanup.runAll();
62
- }
63
- });
64
- }
65
48
  let watcherStarted = false;
66
49
  /**
67
50
  * Sets up a file watcher that rebuilds Mochi CSS whenever source files change.
@@ -76,13 +59,15 @@ async function startCssWatcher(tmpDir) {
76
59
  const resolved = await (0, __mochi_css_config.resolveConfig)(await (0, __mochi_css_config.loadConfig)(), void 0, {});
77
60
  const effectiveTmpDir = resolved.tmpDir ? path.default.resolve(cwd, resolved.tmpDir) : tmpDir;
78
61
  const debug = resolved.debug ?? false;
79
- const absoluteRoots = resolveAbsoluteRoots(cwd, resolved.roots);
80
- if (debug) console.log(`[mochi-css] watcher: roots=${JSON.stringify(absoluteRoots)}, tmpDir=${effectiveTmpDir}`);
81
- if (absoluteRoots.length === 0) {
62
+ resolved.roots = resolveAbsoluteRoots(cwd, resolved.roots);
63
+ if (debug) console.log(`[mochi-css] watcher: roots=${JSON.stringify(resolved.roots)}, tmpDir=${effectiveTmpDir}`);
64
+ if (resolved.roots.length === 0) {
82
65
  console.warn("[mochi-css] watcher: no roots configured — add `roots` to mochi.config.ts");
83
66
  return;
84
67
  }
85
- const builder = createBuilder(resolved, absoluteRoots);
68
+ const context = new __mochi_css_config.FullContext(resolved.onDiagnostic ?? (() => {}));
69
+ for (const plugin of resolved.plugins) plugin.onLoad?.(context);
70
+ const builder = (0, __mochi_css_config.createBuilder)(resolved, context);
86
71
  let rebuildTimer;
87
72
  let rebuildGuard = Promise.resolve();
88
73
  const scheduleRebuild = () => {
@@ -96,7 +81,7 @@ async function startCssWatcher(tmpDir) {
96
81
  }, 50);
97
82
  };
98
83
  scheduleRebuild();
99
- const rootDirs = absoluteRoots.map((root) => __mochi_css_builder.path.toSystemPath(typeof root === "string" ? root : root.path));
84
+ const rootDirs = resolved.roots.map((root) => __mochi_css_builder.path.toSystemPath(typeof root === "string" ? root : root.path));
100
85
  for (const dir of rootDirs) {
101
86
  if (!fs.default.existsSync(dir)) {
102
87
  console.warn(`[mochi-css] watcher: root not found: ${dir}`);
@@ -117,12 +102,14 @@ async function buildCssOnce(tmpDir) {
117
102
  const cwd = process.cwd();
118
103
  const resolved = await (0, __mochi_css_config.resolveConfig)(await (0, __mochi_css_config.loadConfig)(), void 0, {});
119
104
  const effectiveTmpDir = resolved.tmpDir ? path.default.resolve(cwd, resolved.tmpDir) : tmpDir;
120
- const absoluteRoots = resolveAbsoluteRoots(cwd, resolved.roots);
121
- if (absoluteRoots.length === 0) {
105
+ resolved.roots = resolveAbsoluteRoots(cwd, resolved.roots);
106
+ if (resolved.roots.length === 0) {
122
107
  console.warn("[mochi-css] buildCssOnce: no roots configured — add `roots` to mochi.config.ts");
123
108
  return;
124
109
  }
125
- await writeCssFiles(await createBuilder(resolved, absoluteRoots).collectMochiCss(), effectiveTmpDir);
110
+ const context = new __mochi_css_config.FullContext(resolved.onDiagnostic ?? (() => {}));
111
+ for (const plugin of resolved.plugins) plugin.onLoad?.(context);
112
+ await writeCssFiles(await (0, __mochi_css_config.createBuilder)(resolved, context).collectMochiCss(), effectiveTmpDir);
126
113
  }
127
114
 
128
115
  //#endregion
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { createRequire } from "node:module";
2
2
  import path from "path";
3
3
  import fs from "fs";
4
- import { FullContext, loadConfig, resolveConfig } from "@mochi-css/config";
5
- import { Builder, RolldownBundler, VmRunner, fileHash, path as path$1 } from "@mochi-css/builder";
4
+ import { FullContext, createBuilder, loadConfig, resolveConfig } from "@mochi-css/config";
5
+ import { fileHash, path as path$1 } from "@mochi-css/builder";
6
6
 
7
7
  //#region rolldown:runtime
8
8
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
@@ -45,23 +45,6 @@ function resolveAbsoluteRoots(cwd, roots) {
45
45
  path: path$1.resolve(posixCwd, root.path)
46
46
  });
47
47
  }
48
- function createBuilder(resolved, roots) {
49
- const context = new FullContext(resolved.onDiagnostic ?? (() => {}));
50
- for (const plugin of resolved.plugins) plugin.onLoad?.(context);
51
- return new Builder({
52
- roots,
53
- stages: [...context.stages.getAll()],
54
- bundler: new RolldownBundler(),
55
- runner: new VmRunner(),
56
- splitCss: resolved.splitCss,
57
- filePreProcess: ({ content, filePath }) => context.filePreProcess.transform(content, { filePath }),
58
- sourceTransforms: [...context.sourceTransforms.getAll()],
59
- emitHooks: [...context.emitHooks.getAll()],
60
- cleanup: () => {
61
- context.cleanup.runAll();
62
- }
63
- });
64
- }
65
48
  let watcherStarted = false;
66
49
  /**
67
50
  * Sets up a file watcher that rebuilds Mochi CSS whenever source files change.
@@ -76,13 +59,15 @@ async function startCssWatcher(tmpDir) {
76
59
  const resolved = await resolveConfig(await loadConfig(), void 0, {});
77
60
  const effectiveTmpDir = resolved.tmpDir ? path.resolve(cwd, resolved.tmpDir) : tmpDir;
78
61
  const debug = resolved.debug ?? false;
79
- const absoluteRoots = resolveAbsoluteRoots(cwd, resolved.roots);
80
- if (debug) console.log(`[mochi-css] watcher: roots=${JSON.stringify(absoluteRoots)}, tmpDir=${effectiveTmpDir}`);
81
- if (absoluteRoots.length === 0) {
62
+ resolved.roots = resolveAbsoluteRoots(cwd, resolved.roots);
63
+ if (debug) console.log(`[mochi-css] watcher: roots=${JSON.stringify(resolved.roots)}, tmpDir=${effectiveTmpDir}`);
64
+ if (resolved.roots.length === 0) {
82
65
  console.warn("[mochi-css] watcher: no roots configured — add `roots` to mochi.config.ts");
83
66
  return;
84
67
  }
85
- const builder = createBuilder(resolved, absoluteRoots);
68
+ const context = new FullContext(resolved.onDiagnostic ?? (() => {}));
69
+ for (const plugin of resolved.plugins) plugin.onLoad?.(context);
70
+ const builder = createBuilder(resolved, context);
86
71
  let rebuildTimer;
87
72
  let rebuildGuard = Promise.resolve();
88
73
  const scheduleRebuild = () => {
@@ -96,7 +81,7 @@ async function startCssWatcher(tmpDir) {
96
81
  }, 50);
97
82
  };
98
83
  scheduleRebuild();
99
- const rootDirs = absoluteRoots.map((root) => path$1.toSystemPath(typeof root === "string" ? root : root.path));
84
+ const rootDirs = resolved.roots.map((root) => path$1.toSystemPath(typeof root === "string" ? root : root.path));
100
85
  for (const dir of rootDirs) {
101
86
  if (!fs.existsSync(dir)) {
102
87
  console.warn(`[mochi-css] watcher: root not found: ${dir}`);
@@ -117,12 +102,14 @@ async function buildCssOnce(tmpDir) {
117
102
  const cwd = process.cwd();
118
103
  const resolved = await resolveConfig(await loadConfig(), void 0, {});
119
104
  const effectiveTmpDir = resolved.tmpDir ? path.resolve(cwd, resolved.tmpDir) : tmpDir;
120
- const absoluteRoots = resolveAbsoluteRoots(cwd, resolved.roots);
121
- if (absoluteRoots.length === 0) {
105
+ resolved.roots = resolveAbsoluteRoots(cwd, resolved.roots);
106
+ if (resolved.roots.length === 0) {
122
107
  console.warn("[mochi-css] buildCssOnce: no roots configured — add `roots` to mochi.config.ts");
123
108
  return;
124
109
  }
125
- await writeCssFiles(await createBuilder(resolved, absoluteRoots).collectMochiCss(), effectiveTmpDir);
110
+ const context = new FullContext(resolved.onDiagnostic ?? (() => {}));
111
+ for (const plugin of resolved.plugins) plugin.onLoad?.(context);
112
+ await writeCssFiles(await createBuilder(resolved, context).collectMochiCss(), effectiveTmpDir);
126
113
  }
127
114
 
128
115
  //#endregion
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": "4.0.2",
4
+ "version": "6.0.0",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -37,8 +37,8 @@
37
37
  "coverage": "vitest run --coverage"
38
38
  },
39
39
  "dependencies": {
40
- "@mochi-css/builder": "^4.0.1",
41
- "@mochi-css/config": "^4.0.0",
40
+ "@mochi-css/builder": "^6.0.0",
41
+ "@mochi-css/config": "^6.0.0",
42
42
  "diff": "^8.0.3"
43
43
  },
44
44
  "peerDependencies": {