dinou 7.3.0 → 8.0.1

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 (113) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +1 -1
  3. package/cli.js +42 -39
  4. package/dinou/adapters/netlify.js +1 -0
  5. package/dinou/adapters/{node.mjs → node.js} +9 -3
  6. package/dinou/bun/{build.mjs → build.js} +12 -11
  7. package/dinou/cloudflare/{build.mjs → build.js} +15 -11
  8. package/dinou/cloudflare/shims/fs.js +3 -0
  9. package/dinou/constants.js +3 -3
  10. package/dinou/core/asset-extensions.js +5 -5
  11. package/dinou/core/bailout-proxy.js +3 -3
  12. package/dinou/core/build-static-pages.js +21 -17
  13. package/dinou/core/cache-revalidate.js +14 -33
  14. package/dinou/core/cache-slot.js +21 -10
  15. package/dinou/core/config.js +2 -5
  16. package/dinou/core/createScopedName.js +3 -3
  17. package/dinou/core/dinou-paths.js +15 -12
  18. package/dinou/core/{export-static.mjs → export-static.js} +1 -1
  19. package/dinou/core/generate-route-types.js +8 -3
  20. package/dinou/core/generate-static-page.js +6 -5
  21. package/dinou/core/generate-static-rsc.js +15 -10
  22. package/dinou/core/generate-static.js +11 -10
  23. package/dinou/core/generating-isg.js +12 -11
  24. package/dinou/core/get-abs-path-with-ext.js +8 -6
  25. package/dinou/core/get-asset-from-manifest.js +4 -4
  26. package/dinou/core/get-error-jsx.js +12 -9
  27. package/dinou/core/get-file-path-and-dynamic-params.js +7 -4
  28. package/dinou/core/get-jsx.js +19 -13
  29. package/dinou/core/handler.js +73 -33
  30. package/dinou/core/http-adapter.js +6 -2
  31. package/dinou/core/import-module.js +5 -4
  32. package/dinou/core/layout-functions.js +11 -6
  33. package/dinou/core/load-dinou-config.js +10 -4
  34. package/dinou/core/manifest-provider.js +11 -4
  35. package/dinou/core/parse-exports.js +11 -6
  36. package/dinou/core/path-utils.js +2 -2
  37. package/dinou/core/ppr-context.js +11 -11
  38. package/dinou/core/ppr-runtime.js +10 -6
  39. package/dinou/core/render-jsx-to-client-jsx.js +6 -3
  40. package/dinou/core/request-context.js +11 -7
  41. package/dinou/core/resolve-module-ppr.js +2 -2
  42. package/dinou/core/resolve-setup-files.js +70 -69
  43. package/dinou/core/revalidating.js +14 -25
  44. package/dinou/core/route-generator.js +12 -8
  45. package/dinou/core/rsc-renderer.js +13 -2
  46. package/dinou/core/run-ssg.js +9 -4
  47. package/dinou/core/safe-rename.js +3 -3
  48. package/dinou/core/scan-dependency-components.js +9 -3
  49. package/dinou/core/status-manifest.js +5 -5
  50. package/dinou/core/storage-adapter.js +13 -3
  51. package/dinou/core/url-resolver.js +2 -2
  52. package/dinou/core/vfs.js +7 -7
  53. package/dinou/deno/{build.mjs → build.js} +12 -11
  54. package/dinou/esbuild/{build.mjs → build.js} +4 -4
  55. package/dinou/esbuild/{dev.mjs → dev.js} +6 -6
  56. package/dinou/esbuild/helpers-esbuild/{get-config-esbuild-prod.mjs → get-config-esbuild-prod.js} +7 -7
  57. package/dinou/esbuild/helpers-esbuild/{get-config-esbuild.mjs → get-config-esbuild.js} +8 -8
  58. package/dinou/esbuild/helpers-esbuild/{get-esbuild-entries.mjs → get-esbuild-entries.js} +2 -2
  59. package/dinou/esbuild/plugins-esbuild/{assets-plugin.mjs → assets-plugin.js} +1 -1
  60. package/dinou/esbuild/plugins-esbuild/{stable-chunk-names-and-maps-plugin.mjs → stable-chunk-names-and-maps-plugin.js} +1 -1
  61. package/dinou/esbuild/plugins-esbuild/{write-plugin.mjs → write-plugin.js} +1 -1
  62. package/dinou/esbuild/plugins-postcss/postcss-extract-plugin.js +4 -3
  63. package/dinou/esbuild/react-refresh/babel-config.js +5 -1
  64. package/dinou/esbuild/react-refresh/esm-hmr/server.js +7 -4
  65. package/dinou/esbuild/react-refresh/{esm-hmr-plugin.mjs → esm-hmr-plugin.js} +4 -4
  66. package/dinou/esbuild/react-refresh/{react-refresh-runtime.mjs → react-refresh-runtime.js} +1 -1
  67. package/dinou/index.js +40 -19
  68. package/dinou/node/{build.mjs → build.js} +4 -4
  69. package/dinou/node/{bundle-dual-engine.mjs → bundle-dual-engine.js} +13 -12
  70. package/dinou/node/{dev.mjs → dev.js} +27 -22
  71. package/dinou/node/{terminal-status.mjs → terminal-status.js} +1 -1
  72. package/dinou/package.json +8 -7
  73. package/dinou/rollup/postcss.config.js +1 -1
  74. package/dinou/rollup/react-refresh/esm-hmr/server.js +7 -4
  75. package/dinou/rollup/react-refresh/react-refresh-wrap-modules.js +2 -1
  76. package/dinou/rollup/react-refresh/rollup-plugin-esm-hmr.js +23 -16
  77. package/dinou/rollup/rollup-plugins/dinou-asset-plugin.js +6 -5
  78. package/dinou/rollup/rollup-plugins/manifest-generator-plugin.js +2 -1
  79. package/dinou/rollup/rollup-plugins/rollup-plugin-memory.js +3 -2
  80. package/dinou/rollup/rollup-plugins/rollup-plugin-react-client-manifest.js +16 -13
  81. package/dinou/rollup/rollup-plugins/rollup-plugin-server-functions.js +7 -6
  82. package/dinou/rollup/rollup-plugins/rollup-plugin-swc.js +6 -3
  83. package/dinou/rollup/rollup.config.js +27 -23
  84. package/dinou/server.js +21 -26
  85. package/dinou/webpack/helpers/get-webpack-entries.js +14 -11
  86. package/dinou/webpack/loaders/server-functions-loader.js +5 -6
  87. package/dinou/webpack/loaders/swc-loader.js +4 -2
  88. package/dinou/webpack/plugins/manifest-generator-plugin.js +3 -1
  89. package/dinou/webpack/plugins/server-functions-plugin.js +4 -3
  90. package/dinou/webpack/plugins/webpack-memory-plugin.js +3 -2
  91. package/dinou/webpack/postcss.config.js +1 -1
  92. package/dinou/webpack/webpack.config.js +22 -20
  93. package/eject.js +54 -47
  94. package/package.json +9 -8
  95. package/dinou/config.js +0 -1
  96. package/dinou/config.mjs +0 -2
  97. package/dinou/core/css-require-hook.js +0 -64
  98. package/dinou/index.mjs +0 -43
  99. package/dinou/server.mjs +0 -30
  100. /package/dinou/esbuild/helpers-esbuild/{normalize-path.mjs → normalize-path.js} +0 -0
  101. /package/dinou/esbuild/helpers-esbuild/{strip-namespace.mjs → strip-namespace.js} +0 -0
  102. /package/dinou/esbuild/helpers-esbuild/{swc-disk-cache.mjs → swc-disk-cache.js} +0 -0
  103. /package/dinou/esbuild/helpers-esbuild/{update-manifest-for-module.mjs → update-manifest-for-module.js} +0 -0
  104. /package/dinou/esbuild/helpers-esbuild/{write.mjs → write.js} +0 -0
  105. /package/dinou/esbuild/plugins-esbuild/{babel-react-compiler-plugin.mjs → babel-react-compiler-plugin.js} +0 -0
  106. /package/dinou/esbuild/plugins-esbuild/{css-processor-plugin.mjs → css-processor-plugin.js} +0 -0
  107. /package/dinou/esbuild/plugins-esbuild/{manifest-generator-plugin.mjs → manifest-generator-plugin.js} +0 -0
  108. /package/dinou/esbuild/plugins-esbuild/{react-client-manifest-plugin.mjs → react-client-manifest-plugin.js} +0 -0
  109. /package/dinou/esbuild/plugins-esbuild/{server-functions-plugin.mjs → server-functions-plugin.js} +0 -0
  110. /package/dinou/esbuild/plugins-esbuild/{skip-missing-entry-points-plugin.mjs → skip-missing-entry-points-plugin.js} +0 -0
  111. /package/dinou/esbuild/react-refresh/esm-hmr/{client.mjs → client.js} +0 -0
  112. /package/dinou/esbuild/react-refresh/{is-react-refresh-boundary.mjs → is-react-refresh-boundary.js} +0 -0
  113. /package/dinou/node/{port-selector.mjs → port-selector.js} +0 -0
@@ -1,23 +1,29 @@
1
- const path = require("path");
2
- const fs = require("fs");
3
- const postcss = require("rollup-plugin-postcss");
4
- const babel = require("@rollup/plugin-babel").default;
5
- const resolve = require("@rollup/plugin-node-resolve").default;
6
- const commonjs = require("@rollup/plugin-commonjs");
7
- const copy = require("rollup-plugin-copy");
8
- const reactClientManifest = require("./rollup-plugins/rollup-plugin-react-client-manifest.js");
9
- const createScopedName = require("../core/createScopedName.js");
10
- const replace = require("@rollup/plugin-replace");
11
- const json = require("@rollup/plugin-json");
12
- const reactRefreshWrapModules = require("./react-refresh/react-refresh-wrap-modules.js");
13
- const { esmHmrPlugin } = require("./react-refresh/rollup-plugin-esm-hmr.js");
14
- const dinouAssetPlugin = require("./rollup-plugins/dinou-asset-plugin.js");
15
- const tsconfigPaths = require("rollup-plugin-tsconfig-paths");
16
- const serverFunctionsPlugin = require("./rollup-plugins/rollup-plugin-server-functions");
17
- const { regex } = require("../core/asset-extensions.js");
18
- const manifestGeneratorPlugin = require("./rollup-plugins/manifest-generator-plugin.js");
19
- const rollupMemoryPlugin = require("./rollup-plugins/rollup-plugin-memory.js");
20
- const rollupSwcPlugin = require("./rollup-plugins/rollup-plugin-swc.js");
1
+ import path from "node:path";
2
+ import fs from "node:fs";
3
+ import { execSync } from "node:child_process";
4
+ import { fileURLToPath } from "node:url";
5
+ import postcss from "rollup-plugin-postcss";
6
+ import babelModule from "@rollup/plugin-babel";
7
+ import resolveModule from "@rollup/plugin-node-resolve";
8
+ import commonjs from "@rollup/plugin-commonjs";
9
+ import copy from "rollup-plugin-copy";
10
+ import reactClientManifest from "./rollup-plugins/rollup-plugin-react-client-manifest.js";
11
+ import createScopedName from "../core/createScopedName.js";
12
+ import replace from "@rollup/plugin-replace";
13
+ import json from "@rollup/plugin-json";
14
+ import reactRefreshWrapModules from "./react-refresh/react-refresh-wrap-modules.js";
15
+ import { esmHmrPlugin } from "./react-refresh/rollup-plugin-esm-hmr.js";
16
+ import dinouAssetPlugin from "./rollup-plugins/dinou-asset-plugin.js";
17
+ import tsconfigPaths from "rollup-plugin-tsconfig-paths";
18
+ import serverFunctionsPlugin from "./rollup-plugins/rollup-plugin-server-functions.js";
19
+ import { regex } from "../core/asset-extensions.js";
20
+ import manifestGeneratorPlugin from "./rollup-plugins/manifest-generator-plugin.js";
21
+ import rollupMemoryPlugin from "./rollup-plugins/rollup-plugin-memory.js";
22
+ import rollupSwcPlugin from "./rollup-plugins/rollup-plugin-swc.js";
23
+
24
+ const babel = babelModule?.default || babelModule;
25
+ const resolve = resolveModule?.default || resolveModule;
26
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
21
27
 
22
28
  const localDinouPath = path.resolve(process.cwd(), "dinou");
23
29
  const isEjected = fs.existsSync(localDinouPath);
@@ -28,7 +34,7 @@ console.log(
28
34
  : "📦 [Dinou] Library Mode detected (Using node_modules)",
29
35
  );
30
36
 
31
- module.exports = async function () {
37
+ export default async function () {
32
38
  const isDevelopment = process.env.NODE_ENV !== "production";
33
39
  const outputDirectory = isDevelopment ? ".dinou/public" : ".dinou/dist3";
34
40
  const shouldWriteToDisk = process.env.DINOU_WRITE_TO_DISK === "true" || !isDevelopment;
@@ -284,12 +290,10 @@ module.exports = async function () {
284
290
  {
285
291
  name: "post-build-server",
286
292
  closeBundle() {
287
- const fs = require("fs");
288
293
  fs.writeFileSync(
289
294
  path.resolve(process.cwd(), ".dinou/dist3/server/package.json"),
290
295
  JSON.stringify({ type: "module" }, null, 2)
291
296
  );
292
- const { execSync } = require("child_process");
293
297
  execSync(`"${process.execPath}" --conditions=react-server "${path.resolve(__dirname, "../core/run-ssg.js")}"`, {
294
298
  stdio: "inherit",
295
299
  env: { ...process.env, NODE_ENV: "production" },
package/dinou/server.js CHANGED
@@ -1,29 +1,24 @@
1
- const {
2
- StorageAdapter,
3
- FileSystemStorage,
4
- CloudflareKVStorage,
5
- DenoKVStorage,
6
- MemoryStorage,
7
- RedisStorage,
8
- getStorageAdapter,
9
- setStorageAdapter,
10
- } = require("./core/storage-adapter.js");
11
- const { DinouCacheSlot } = require("./core/cache-slot.js");
1
+ export async function revalidatePath(path, options) {
2
+ const { revalidatePath: fn } = await import("./core/cache-revalidate.js");
3
+ return fn(path, options);
4
+ }
5
+
6
+ export async function revalidatePage(path) {
7
+ const { revalidatePage: fn } = await import("./core/cache-revalidate.js");
8
+ return fn(path);
9
+ }
10
+
11
+ export async function revalidateTag(tag, options) {
12
+ const { revalidateTag: fn } = await import("./core/cache-revalidate.js");
13
+ return fn(tag, options);
14
+ }
15
+
16
+ export async function DinouCacheSlot(props) {
17
+ const { DinouCacheSlot: fn } = await import("./core/cache-slot.js");
18
+ return fn(props);
19
+ }
12
20
 
13
- module.exports = {
14
- DinouCacheSlot,
15
- revalidatePath: async function (path, options) {
16
- const { revalidatePath: fn } = require("./core/cache-revalidate.js");
17
- return fn(path, options);
18
- },
19
- revalidatePage: async function (path) {
20
- const { revalidatePage: fn } = require("./core/cache-revalidate.js");
21
- return fn(path);
22
- },
23
- revalidateTag: async function (tag, options) {
24
- const { revalidateTag: fn } = require("./core/cache-revalidate.js");
25
- return fn(tag, options);
26
- },
21
+ export {
27
22
  StorageAdapter,
28
23
  FileSystemStorage,
29
24
  CloudflareKVStorage,
@@ -32,4 +27,4 @@ module.exports = {
32
27
  RedisStorage,
33
28
  getStorageAdapter,
34
29
  setStorageAdapter,
35
- };
30
+ } from "./core/storage-adapter.js";
@@ -1,13 +1,15 @@
1
- const { readFileSync } = require("fs");
2
- const path = require("node:path");
3
- const glob = require("fast-glob");
4
- const { pathToFileURL } = require("node:url");
5
- const parser = require("@babel/parser");
6
- const traverse = require("@babel/traverse");
7
- const crypto = require("node:crypto");
8
- const { regex: assetRegex } = require("../../core/asset-extensions.js");
9
- const { getAbsPathWithExt } = require("../../core/get-abs-path-with-ext.js");
10
- const { useClientRegex, useServerRegex } = require("../../constants.js");
1
+ import { readFileSync } from "node:fs";
2
+ import path from "node:path";
3
+ import glob from "fast-glob";
4
+ import { pathToFileURL } from "node:url";
5
+ import parser from "@babel/parser";
6
+ import _traverseRaw from "@babel/traverse";
7
+ import crypto from "node:crypto";
8
+ import { regex as assetRegex } from "../../core/asset-extensions.js";
9
+ import { getAbsPathWithExt } from "../../core/get-abs-path-with-ext.js";
10
+ import { useClientRegex, useServerRegex } from "../../constants.js";
11
+
12
+ const traverse = typeof _traverseRaw === "function" ? _traverseRaw : (_traverseRaw.default || _traverseRaw);
11
13
 
12
14
  const normalizePath = (p) => p.split(path.sep).join(path.posix.sep);
13
15
 
@@ -203,4 +205,5 @@ async function getCSSEntries({
203
205
  return [detectedCSSEntries, detectedClientEntries, serverFiles];
204
206
  }
205
207
 
206
- module.exports = getCSSEntries;
208
+ export { getCSSEntries };
209
+ export default getCSSEntries;
@@ -1,10 +1,9 @@
1
- const path = require("path");
1
+ import path from "node:path";
2
+ import { normalizePathCase } from "../../core/path-utils.js";
3
+ import parseExports from "../../core/parse-exports.js";
4
+ import { useServerRegex } from "../../constants.js";
2
5
 
3
- const { normalizePathCase } = require("../../core/path-utils.js");
4
- const parseExports = require("../../core/parse-exports.js");
5
- const { useServerRegex } = require("../../constants.js");
6
-
7
- module.exports = function (source) {
6
+ export default function (source) {
8
7
  const options = this.getOptions ? this.getOptions() : {};
9
8
  const norm = path.resolve(this.resourcePath).replace(/\\/g, "/").toLowerCase();
10
9
 
@@ -2,8 +2,10 @@
2
2
  // Ultra-fast SWC transpilation loader for Webpack.
3
3
  // Replaces heavy Babel pipeline in development and eliminates multi-second rebuild latencies.
4
4
 
5
- const path = require("path");
5
+ import path from "node:path";
6
+ import { createRequire } from "node:module";
6
7
 
8
+ const require = createRequire(import.meta.url);
7
9
  let swc = null;
8
10
  try {
9
11
  swc = require("@swc/core");
@@ -11,7 +13,7 @@ try {
11
13
  // Handled on first invocation
12
14
  }
13
15
 
14
- module.exports = function (source, inputSourceMap) {
16
+ export default function (source, inputSourceMap) {
15
17
  if (this.cacheable) this.cacheable(true);
16
18
 
17
19
  if (!swc) {
@@ -43,4 +43,6 @@ class ManifestGeneratorPlugin {
43
43
  }
44
44
  }
45
45
 
46
- module.exports = new ManifestGeneratorPlugin();
46
+ const instance = new ManifestGeneratorPlugin();
47
+ export { ManifestGeneratorPlugin, instance };
48
+ export default instance;
@@ -1,5 +1,5 @@
1
- const path = require("path");
2
- const manifestGeneratorPlugin = require("./manifest-generator-plugin");
1
+ import path from "node:path";
2
+ import manifestGeneratorPlugin from "./manifest-generator-plugin.js";
3
3
 
4
4
  class WebpackServerFunctionsPluginSimple {
5
5
  constructor() {
@@ -130,4 +130,5 @@ class WebpackServerFunctionsPluginSimple {
130
130
  }
131
131
  }
132
132
 
133
- module.exports = WebpackServerFunctionsPluginSimple;
133
+ export { WebpackServerFunctionsPluginSimple };
134
+ export default WebpackServerFunctionsPluginSimple;
@@ -2,7 +2,7 @@
2
2
  // Captures Webpack client assets, chunks, manifests, and sourcemaps in memory (globalThis.__DINOU_MEM_FILES__)
3
3
  // and sets global raw manifests in dev mode to prevent massive disk writes.
4
4
 
5
- const path = require("path");
5
+ import path from "node:path";
6
6
 
7
7
  class WebpackMemoryPlugin {
8
8
  constructor(options = {}) {
@@ -63,4 +63,5 @@ class WebpackMemoryPlugin {
63
63
  }
64
64
  }
65
65
 
66
- module.exports = WebpackMemoryPlugin;
66
+ export { WebpackMemoryPlugin };
67
+ export default WebpackMemoryPlugin;
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  plugins: {
3
3
  "@tailwindcss/postcss": {},
4
4
  autoprefixer: {},
@@ -1,22 +1,26 @@
1
- require("dotenv/config");
2
- const path = require("path");
3
- const fs = require("fs");
4
- const ReactServerWebpackPlugin = require("react-server-dom-webpack/plugin");
5
- const CopyWebpackPlugin = require("copy-webpack-plugin");
6
- const MiniCssExtractPlugin = require("mini-css-extract-plugin");
7
- const createScopedName = require("../core/createScopedName");
8
- const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
9
- const manifestGeneratorPlugin = require("./plugins/manifest-generator-plugin");
10
- const ServerFunctionsPlugin = require("./plugins/server-functions-plugin");
11
- const WebpackMemoryPlugin = require("./plugins/webpack-memory-plugin");
12
- const webpack = require("webpack");
13
- const { regex } = require("../core/asset-extensions");
14
- const getCSSEntries = require("./helpers/get-webpack-entries");
15
- const {
1
+ import "dotenv/config";
2
+ import path from "node:path";
3
+ import fs from "node:fs";
4
+ import { execSync } from "node:child_process";
5
+ import { fileURLToPath } from "node:url";
6
+ import ReactServerWebpackPlugin from "react-server-dom-webpack/plugin";
7
+ import CopyWebpackPlugin from "copy-webpack-plugin";
8
+ import MiniCssExtractPlugin from "mini-css-extract-plugin";
9
+ import createScopedName from "../core/createScopedName.js";
10
+ import TsconfigPathsPlugin from "tsconfig-paths-webpack-plugin";
11
+ import manifestGeneratorPlugin from "./plugins/manifest-generator-plugin.js";
12
+ import ServerFunctionsPlugin from "./plugins/server-functions-plugin.js";
13
+ import WebpackMemoryPlugin from "./plugins/webpack-memory-plugin.js";
14
+ import webpack from "webpack";
15
+ import { regex } from "../core/asset-extensions.js";
16
+ import getCSSEntries from "./helpers/get-webpack-entries.js";
17
+ import {
16
18
  scanProjectDependenciesForClientComponents,
17
19
  scanProjectDependenciesForClientComponentsAsync,
18
- } = require("../core/scan-dependency-components.js");
19
- const { useClientRegex } = require("../constants.js");
20
+ } from "../core/scan-dependency-components.js";
21
+ import { useClientRegex } from "../constants.js";
22
+
23
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
20
24
 
21
25
  const isDevelopment = process.env.NODE_ENV !== "production";
22
26
  const outputDirectory = isDevelopment ? ".dinou/public" : ".dinou/dist3";
@@ -67,7 +71,7 @@ function cleanDir(dir) {
67
71
  }
68
72
  }
69
73
 
70
- module.exports = async () => {
74
+ export default async () => {
71
75
  const outputDir = path.resolve(process.cwd(), outputDirectory);
72
76
 
73
77
  const shouldWriteToDisk =
@@ -101,14 +105,12 @@ module.exports = async () => {
101
105
  function runPostBuild() {
102
106
  if (clientDone && serverDone && !ssgExecuted) {
103
107
  ssgExecuted = true;
104
- const fs = require("fs");
105
108
  const serverDir = path.resolve(process.cwd(), ".dinou/dist3/server");
106
109
  fs.mkdirSync(serverDir, { recursive: true });
107
110
  fs.writeFileSync(
108
111
  path.join(serverDir, "package.json"),
109
112
  JSON.stringify({ type: "module" }, null, 2)
110
113
  );
111
- const { execSync } = require("child_process");
112
114
  execSync(`"${process.execPath}" --conditions=react-server "${path.resolve(__dirname, "../core/run-ssg.js")}"`, {
113
115
  stdio: "inherit",
114
116
  env: { ...process.env, NODE_ENV: "production", DINOU_BUILD_TOOL: "webpack" },
package/eject.js CHANGED
@@ -1,11 +1,15 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
- const { execSync } = require("child_process");
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { execSync } from "node:child_process";
4
+ import { fileURLToPath } from "node:url";
4
5
 
6
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
5
7
  const dinouPath = path.resolve(__dirname, "dinou");
6
8
  const projectRoot = process.cwd();
7
9
 
8
- console.log("🚀 Starting Dinou ejecting process...");
10
+
11
+ export function eject() {
12
+ console.log("🚀 Starting Dinou ejecting process...");
9
13
 
10
14
  fs.cpSync(dinouPath, path.join(projectRoot, "dinou"), {
11
15
  recursive: true,
@@ -13,7 +17,7 @@ fs.cpSync(dinouPath, path.join(projectRoot, "dinou"), {
13
17
  console.log("✅ Files copied to ./dinou");
14
18
 
15
19
  const pkgPath = path.join(projectRoot, "package.json");
16
- const pkg = require(pkgPath);
20
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
17
21
 
18
22
  pkg.scripts = pkg.scripts || {};
19
23
 
@@ -21,13 +25,13 @@ const ejectedScripts = {
21
25
  dev: "npm run dev:esbuild",
22
26
  build: "npm run build:node",
23
27
  start: "npm run start:node",
24
- "dev:esbuild": "cross-env DINOU_BUILD_TOOL=esbuild node dinou/node/dev.mjs",
25
- "dev:rollup": "cross-env DINOU_BUILD_TOOL=rollup node dinou/node/dev.mjs",
26
- "dev:webpack": "cross-env DINOU_BUILD_TOOL=webpack node dinou/node/dev.mjs",
27
- "build:node": "npm run build:client:esbuild && node ./dinou/node/build.mjs",
28
+ "dev:esbuild": "cross-env DINOU_BUILD_TOOL=esbuild node dinou/node/dev.js",
29
+ "dev:rollup": "cross-env DINOU_BUILD_TOOL=rollup node dinou/node/dev.js",
30
+ "dev:webpack": "cross-env DINOU_BUILD_TOOL=webpack node dinou/node/dev.js",
31
+ "build:node": "npm run build:client:esbuild && node ./dinou/node/build.js",
28
32
  "build:node:esbuild": "npm run build:node",
29
- "build:node:rollup": "npm run build:client:rollup && node ./dinou/node/build.mjs",
30
- "build:node:webpack": "npm run build:client:webpack && cross-env DINOU_BUILD_TOOL=webpack node ./dinou/node/build.mjs",
33
+ "build:node:rollup": "npm run build:client:rollup && node ./dinou/node/build.js",
34
+ "build:node:webpack": "npm run build:client:webpack && cross-env DINOU_BUILD_TOOL=webpack node ./dinou/node/build.js",
31
35
  "build:node:compile": "npm run build:node:compile:esbuild",
32
36
  "build:node:compile:esbuild": "npm run build:node:esbuild && bun build --compile .dinou/node/server.mjs --outfile dist/server",
33
37
  "build:node:compile:rollup": "npm run build:node:rollup && bun build --compile .dinou/node/server.mjs --outfile dist/server",
@@ -49,41 +53,41 @@ const ejectedScripts = {
49
53
  "build:node:compile:win:rollup": "npm run build:node:rollup && bun build --compile --target=bun-windows-x64 .dinou/node/server.mjs --outfile dist/server-win",
50
54
  "build:node:compile:win:webpack": "npm run build:node:webpack && bun build --compile --target=bun-windows-x64 .dinou/node/server.mjs --outfile dist/server-win",
51
55
  "build:node:pure": "npm run build:node:pure:esbuild",
52
- "build:node:pure:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.mjs && bun ./dinou/node/build.mjs",
53
- "build:node:pure:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.mjs",
54
- "build:node:pure:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.mjs",
56
+ "build:node:pure:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.js && bun ./dinou/node/build.js",
57
+ "build:node:pure:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.js",
58
+ "build:node:pure:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.js",
55
59
  "build:node:pure:compile": "npm run build:node:pure:compile:esbuild",
56
- "build:node:pure:compile:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.mjs && bun ./dinou/node/build.mjs && bun build --compile .dinou/node/server.mjs --outfile dist/server",
57
- "build:node:pure:compile:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.mjs && bun build --compile .dinou/node/server.mjs --outfile dist/server",
58
- "build:node:pure:compile:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.mjs && bun build --compile .dinou/node/server.mjs --outfile dist/server",
60
+ "build:node:pure:compile:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.js && bun ./dinou/node/build.js && bun build --compile .dinou/node/server.mjs --outfile dist/server",
61
+ "build:node:pure:compile:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.js && bun build --compile .dinou/node/server.mjs --outfile dist/server",
62
+ "build:node:pure:compile:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.js && bun build --compile .dinou/node/server.mjs --outfile dist/server",
59
63
  "build:node:pure:compile:linux": "npm run build:node:pure:compile:linux:esbuild",
60
- "build:node:pure:compile:linux:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.mjs && bun ./dinou/node/build.mjs && bun build --compile --target=bun-linux-x64 .dinou/node/server.mjs --outfile dist/server-linux",
61
- "build:node:pure:compile:linux:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.mjs && bun build --compile --target=bun-linux-x64 .dinou/node/server.mjs --outfile dist/server-linux",
62
- "build:node:pure:compile:linux:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.mjs && bun build --compile --target=bun-linux-x64 .dinou/node/server.mjs --outfile dist/server-linux",
64
+ "build:node:pure:compile:linux:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.js && bun ./dinou/node/build.js && bun build --compile --target=bun-linux-x64 .dinou/node/server.mjs --outfile dist/server-linux",
65
+ "build:node:pure:compile:linux:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.js && bun build --compile --target=bun-linux-x64 .dinou/node/server.mjs --outfile dist/server-linux",
66
+ "build:node:pure:compile:linux:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.js && bun build --compile --target=bun-linux-x64 .dinou/node/server.mjs --outfile dist/server-linux",
63
67
  "build:node:pure:compile:linux_arm": "npm run build:node:pure:compile:linux_arm:esbuild",
64
- "build:node:pure:compile:linux_arm:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.mjs && bun ./dinou/node/build.mjs && bun build --compile --target=bun-linux-arm64 .dinou/node/server.mjs --outfile dist/server-linux-arm",
65
- "build:node:pure:compile:linux_arm:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.mjs && bun build --compile --target=bun-linux-arm64 .dinou/node/server.mjs --outfile dist/server-linux-arm",
66
- "build:node:pure:compile:linux_arm:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.mjs && bun build --compile --target=bun-linux-arm64 .dinou/node/server.mjs --outfile dist/server-linux-arm",
68
+ "build:node:pure:compile:linux_arm:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.js && bun ./dinou/node/build.js && bun build --compile --target=bun-linux-arm64 .dinou/node/server.mjs --outfile dist/server-linux-arm",
69
+ "build:node:pure:compile:linux_arm:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.js && bun build --compile --target=bun-linux-arm64 .dinou/node/server.mjs --outfile dist/server-linux-arm",
70
+ "build:node:pure:compile:linux_arm:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.js && bun build --compile --target=bun-linux-arm64 .dinou/node/server.mjs --outfile dist/server-linux-arm",
67
71
  "build:node:pure:compile:mac": "npm run build:node:pure:compile:mac:esbuild",
68
- "build:node:pure:compile:mac:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.mjs && bun ./dinou/node/build.mjs && bun build --compile --target=bun-darwin-arm64 .dinou/node/server.mjs --outfile dist/server-mac",
69
- "build:node:pure:compile:mac:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.mjs && bun build --compile --target=bun-darwin-arm64 .dinou/node/server.mjs --outfile dist/server-mac",
70
- "build:node:pure:compile:mac:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.mjs && bun build --compile --target=bun-darwin-arm64 .dinou/node/server.mjs --outfile dist/server-mac",
72
+ "build:node:pure:compile:mac:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.js && bun ./dinou/node/build.js && bun build --compile --target=bun-darwin-arm64 .dinou/node/server.mjs --outfile dist/server-mac",
73
+ "build:node:pure:compile:mac:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.js && bun build --compile --target=bun-darwin-arm64 .dinou/node/server.mjs --outfile dist/server-mac",
74
+ "build:node:pure:compile:mac:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.js && bun build --compile --target=bun-darwin-arm64 .dinou/node/server.mjs --outfile dist/server-mac",
71
75
  "build:node:pure:compile:win": "npm run build:node:pure:compile:win:esbuild",
72
- "build:node:pure:compile:win:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.mjs && bun ./dinou/node/build.mjs && bun build --compile --target=bun-windows-x64 .dinou/node/server.mjs --outfile dist/server-win",
73
- "build:node:pure:compile:win:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.mjs && bun build --compile --target=bun-windows-x64 .dinou/node/server.mjs --outfile dist/server-win",
74
- "build:node:pure:compile:win:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.mjs && bun build --compile --target=bun-windows-x64 .dinou/node/server.mjs --outfile dist/server-win",
75
- "start:node": "cross-env NODE_ENV=production node dinou/adapters/node.mjs",
76
+ "build:node:pure:compile:win:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.js && bun ./dinou/node/build.js && bun build --compile --target=bun-windows-x64 .dinou/node/server.mjs --outfile dist/server-win",
77
+ "build:node:pure:compile:win:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/node/build.js && bun build --compile --target=bun-windows-x64 .dinou/node/server.mjs --outfile dist/server-win",
78
+ "build:node:pure:compile:win:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/node/build.js && bun build --compile --target=bun-windows-x64 .dinou/node/server.mjs --outfile dist/server-win",
79
+ "start:node": "cross-env NODE_ENV=production node dinou/adapters/node.js",
76
80
  "start:node:esbuild": "npm run start:node",
77
81
  "start:node:rollup": "npm run start:node",
78
- "start:node:webpack": "cross-env NODE_ENV=production DINOU_BUILD_TOOL=webpack node dinou/adapters/node.mjs",
79
- "build:cloudflare": "npm run build:client:esbuild && node ./dinou/cloudflare/build.mjs",
82
+ "start:node:webpack": "cross-env NODE_ENV=production DINOU_BUILD_TOOL=webpack node dinou/adapters/node.js",
83
+ "build:cloudflare": "npm run build:client:esbuild && node ./dinou/cloudflare/build.js",
80
84
  "build:cloudflare:esbuild": "npm run build:cloudflare",
81
- "build:cloudflare:rollup": "npm run build:client:rollup && node ./dinou/cloudflare/build.mjs",
82
- "build:cloudflare:webpack": "npm run build:client:webpack && cross-env DINOU_BUILD_TOOL=webpack node ./dinou/cloudflare/build.mjs",
83
- "build:deno": "npm run build:client:esbuild && node ./dinou/deno/build.mjs && deno run --unstable-kv --allow-net --allow-read --allow-write --allow-env dinou/deno/seed-kv.js",
85
+ "build:cloudflare:rollup": "npm run build:client:rollup && node ./dinou/cloudflare/build.js",
86
+ "build:cloudflare:webpack": "npm run build:client:webpack && cross-env DINOU_BUILD_TOOL=webpack node ./dinou/cloudflare/build.js",
87
+ "build:deno": "npm run build:client:esbuild && node ./dinou/deno/build.js && deno run --unstable-kv --allow-net --allow-read --allow-write --allow-env dinou/deno/seed-kv.js",
84
88
  "build:deno:esbuild": "npm run build:deno",
85
- "build:deno:rollup": "npm run build:client:rollup && node ./dinou/deno/build.mjs && deno run --unstable-kv --allow-net --allow-read --allow-write --allow-env dinou/deno/seed-kv.js",
86
- "build:deno:webpack": "npm run build:client:webpack && cross-env DINOU_BUILD_TOOL=webpack node ./dinou/deno/build.mjs && deno run --unstable-kv --allow-net --allow-read --allow-write --allow-env dinou/deno/seed-kv.js",
89
+ "build:deno:rollup": "npm run build:client:rollup && node ./dinou/deno/build.js && deno run --unstable-kv --allow-net --allow-read --allow-write --allow-env dinou/deno/seed-kv.js",
90
+ "build:deno:webpack": "npm run build:client:webpack && cross-env DINOU_BUILD_TOOL=webpack node ./dinou/deno/build.js && deno run --unstable-kv --allow-net --allow-read --allow-write --allow-env dinou/deno/seed-kv.js",
87
91
  "build:deno:compile": "npm run build:deno:compile:esbuild",
88
92
  "build:deno:compile:esbuild": "npm run build:deno:esbuild && deno compile --no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output dist/deno-server .dinou/deno/main.js",
89
93
  "build:deno:compile:rollup": "npm run build:deno:rollup && deno compile --no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output dist/deno-server .dinou/deno/main.js",
@@ -105,10 +109,10 @@ const ejectedScripts = {
105
109
  "build:deno:compile:win:rollup": "npm run build:deno:rollup && deno compile --target x86_64-pc-windows-msvc --no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output dist/deno-server-win .dinou/deno/main.js",
106
110
  "build:deno:compile:win:webpack": "npm run build:deno:webpack && deno compile --target x86_64-pc-windows-msvc --no-check --no-config --allow-net --allow-read --allow-write --allow-env --allow-sys --output dist/deno-server-win .dinou/deno/main.js",
107
111
  "start:deno": "deno run --unstable-kv --allow-net --allow-read --allow-write --allow-env --allow-sys dinou/adapters/deno.js",
108
- "build:bun": "npm run build:client:esbuild && node ./dinou/bun/build.mjs",
112
+ "build:bun": "npm run build:client:esbuild && node ./dinou/bun/build.js",
109
113
  "build:bun:esbuild": "npm run build:bun",
110
- "build:bun:rollup": "npm run build:client:rollup && node ./dinou/bun/build.mjs",
111
- "build:bun:webpack": "npm run build:client:webpack && cross-env DINOU_BUILD_TOOL=webpack node ./dinou/bun/build.mjs",
114
+ "build:bun:rollup": "npm run build:client:rollup && node ./dinou/bun/build.js",
115
+ "build:bun:webpack": "npm run build:client:webpack && cross-env DINOU_BUILD_TOOL=webpack node ./dinou/bun/build.js",
112
116
  "build:bun:compile": "npm run build:bun:compile:esbuild",
113
117
  "build:bun:compile:esbuild": "npm run build:bun:esbuild && bun build --compile .dinou/bun/server.js --outfile dist/server",
114
118
  "build:bun:compile:rollup": "npm run build:bun:rollup && bun build --compile .dinou/bun/server.js --outfile dist/server",
@@ -130,9 +134,9 @@ const ejectedScripts = {
130
134
  "build:bun:compile:win:rollup": "npm run build:bun:rollup && bun build --compile --target=bun-windows-x64 .dinou/bun/server.js --outfile dist/server-win",
131
135
  "build:bun:compile:win:webpack": "npm run build:bun:webpack && bun build --compile --target=bun-windows-x64 .dinou/bun/server.js --outfile dist/server-win",
132
136
  "build:bun:pure": "npm run build:bun:pure:esbuild",
133
- "build:bun:pure:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.mjs && bun ./dinou/bun/build.mjs",
134
- "build:bun:pure:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/bun/build.mjs",
135
- "build:bun:pure:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/bun/build.mjs",
137
+ "build:bun:pure:esbuild": "cross-env NODE_ENV=production bun dinou/esbuild/build.js && bun ./dinou/bun/build.js",
138
+ "build:bun:pure:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js && bun ./dinou/bun/build.js",
139
+ "build:bun:pure:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js && cross-env DINOU_BUILD_TOOL=webpack bun ./dinou/bun/build.js",
136
140
  "build:bun:pure:compile": "npm run build:bun:pure:compile:esbuild",
137
141
  "build:bun:pure:compile:esbuild": "npm run build:bun:pure:esbuild && bun build --compile .dinou/bun/server.js --outfile dist/server",
138
142
  "build:bun:pure:compile:rollup": "npm run build:bun:pure:rollup && bun build --compile .dinou/bun/server.js --outfile dist/server",
@@ -158,10 +162,10 @@ const ejectedScripts = {
158
162
  "start:bun:rollup": "npm run start:bun",
159
163
  "start:bun:webpack": "cross-env NODE_ENV=production DINOU_BUILD_TOOL=webpack bun dinou/adapters/bun.js",
160
164
  "export-static": "npm run export-static:esbuild",
161
- "export-static:esbuild": "npm run build:client:esbuild && node ./dinou/core/export-static.mjs",
162
- "export-static:rollup": "npm run build:client:rollup && node ./dinou/core/export-static.mjs",
163
- "export-static:webpack": "npm run build:client:webpack && node ./dinou/core/export-static.mjs",
164
- "build:client:esbuild": "cross-env NODE_ENV=production node dinou/esbuild/build.mjs",
165
+ "export-static:esbuild": "npm run build:client:esbuild && node ./dinou/core/export-static.js",
166
+ "export-static:rollup": "npm run build:client:rollup && node ./dinou/core/export-static.js",
167
+ "export-static:webpack": "npm run build:client:webpack && node ./dinou/core/export-static.js",
168
+ "build:client:esbuild": "cross-env NODE_ENV=production node dinou/esbuild/build.js",
165
169
  "build:client:rollup": "cross-env NODE_ENV=production rollup -c ./dinou/rollup/rollup.config.js",
166
170
  "build:client:webpack": "cross-env NODE_ENV=production webpack --config dinou/webpack/webpack.config.js",
167
171
  };
@@ -215,3 +219,6 @@ try {
215
219
  console.log(
216
220
  "🎉 Eject completed successfully! Dinou is now running from local source.",
217
221
  );
222
+ }
223
+
224
+ export default eject;
package/package.json CHANGED
@@ -1,31 +1,32 @@
1
1
  {
2
2
  "name": "dinou",
3
- "version": "7.3.0",
3
+ "version": "8.0.1",
4
4
  "description": "Full-stack React 19 framework with native RSC, Server Functions, progressive streaming, and zero vendor lock-in.",
5
- "main": "index.js",
5
+ "type": "module",
6
+ "main": "./dinou/index.js",
6
7
  "bin": {
7
8
  "dinou": "./cli.js"
8
9
  },
9
10
  "exports": {
10
11
  ".": {
11
12
  "types": "./dinou/index.d.ts",
12
- "import": "./dinou/index.mjs",
13
- "require": "./dinou/index.js"
13
+ "import": "./dinou/index.js",
14
+ "default": "./dinou/index.js"
14
15
  },
15
16
  "./env": {
16
17
  "types": "./dinou/env.d.ts"
17
18
  },
18
19
  "./server": {
19
20
  "types": "./dinou/server.d.ts",
20
- "import": "./dinou/server.mjs",
21
- "require": "./dinou/server.js"
21
+ "import": "./dinou/server.js",
22
+ "default": "./dinou/server.js"
22
23
  },
23
24
  "./config": {
24
25
  "types": "./dinou/index.d.ts",
25
26
  "import": "./dinou/core/config.js",
26
- "require": "./dinou/core/config.js"
27
+ "default": "./dinou/core/config.js"
27
28
  },
28
- "./adapters/node": "./dinou/adapters/node.mjs",
29
+ "./adapters/node": "./dinou/adapters/node.js",
29
30
  "./adapters/bun": "./dinou/adapters/bun.js",
30
31
  "./adapters/deno": "./dinou/adapters/deno.js",
31
32
  "./adapters/cloudflare": "./dinou/adapters/cloudflare.js",
package/dinou/config.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require("./core/config.js");
package/dinou/config.mjs DELETED
@@ -1,2 +0,0 @@
1
- export * from "./core/config.js";
2
- export { default } from "./core/config.js";
@@ -1,64 +0,0 @@
1
- const fs = require("fs");
2
- const postcss = require("postcss");
3
- const createScopedName = require("./createScopedName");
4
-
5
- function registerCSSRequireHook() {
6
- require.extensions[".css"] = function (module, filename) {
7
- const cssContent = fs.readFileSync(filename, "utf8");
8
- const jsonResult = {};
9
-
10
- const plugin = {
11
- postcssPlugin: "extract-classes",
12
- Rule(rule) {
13
- // Ignore classes inside animations (@keyframes)
14
- if (rule.parent && rule.parent.name === "keyframes") {
15
- return;
16
- }
17
-
18
- const selector = rule.selector;
19
- // Regex to capture valid class names
20
- const classRegex = /\.([_a-zA-Z0-9-]+)/g;
21
- let match;
22
-
23
- while ((match = classRegex.exec(selector)) !== null) {
24
- const className = match[1];
25
-
26
- // Handle :global and :local selectors
27
- const index = match.index;
28
- const before = selector.slice(0, index);
29
- const lastGlobal = before.lastIndexOf(":global");
30
- const lastLocal = before.lastIndexOf(":local");
31
-
32
- // If the class is under an active :global scope, do not hash it
33
- if (lastGlobal > lastLocal) {
34
- const afterGlobal = before.slice(lastGlobal);
35
- if (afterGlobal.includes("(")) {
36
- const openParens = afterGlobal.split("(").length - 1;
37
- const closeParens = afterGlobal.split(")").length - 1;
38
- if (openParens > closeParens) {
39
- jsonResult[className] = className;
40
- continue;
41
- }
42
- } else {
43
- // Example: :global .my-class (without parentheses)
44
- jsonResult[className] = className;
45
- continue;
46
- }
47
- }
48
-
49
- // If it is a local class, generate the corresponding deterministic hash
50
- if (!jsonResult[className]) {
51
- jsonResult[className] = createScopedName(className, filename);
52
- }
53
- }
54
- }
55
- };
56
-
57
- // Process strictly synchronously (PostCSS is synchronous if its plugins are)
58
- postcss([plugin]).process(cssContent, { from: filename }).css;
59
-
60
- module.exports = jsonResult;
61
- };
62
- }
63
-
64
- module.exports = registerCSSRequireHook;