fuma-content 0.0.2 → 1.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.
Files changed (74) hide show
  1. package/dist/bin.d.ts +1 -0
  2. package/dist/bin.js +18 -0
  3. package/dist/build-mdx-Q4RMDWYK.js +8 -0
  4. package/dist/bun/index.d.ts +16 -0
  5. package/dist/bun/index.js +36 -0
  6. package/dist/bun-DMNX4PBC.js +40 -0
  7. package/dist/chunk-3VQS3KSP.js +39 -0
  8. package/dist/chunk-4RMSJCK2.js +50 -0
  9. package/dist/chunk-6XDQG2GV.js +17 -0
  10. package/dist/chunk-AMBGM4OK.js +412 -0
  11. package/dist/chunk-BTRE6MOX.js +16 -0
  12. package/dist/chunk-E4HRKSP4.js +24 -0
  13. package/dist/chunk-ERBMAQYP.js +33 -0
  14. package/dist/chunk-IGLM4N4P.js +34 -0
  15. package/dist/chunk-LDBQ66H3.js +38 -0
  16. package/dist/chunk-M72VQL5M.js +40 -0
  17. package/dist/chunk-OUJENWQ4.js +45 -0
  18. package/dist/chunk-PNA5UGSL.js +104 -0
  19. package/dist/chunk-RMSV4HP6.js +85 -0
  20. package/dist/chunk-RXR7OL76.js +37 -0
  21. package/dist/chunk-VWJKRQZR.js +19 -0
  22. package/dist/chunk-Z7KHD7MS.js +368 -0
  23. package/dist/collections/handlers/fs.d.ts +10 -0
  24. package/dist/collections/handlers/fs.js +6 -0
  25. package/dist/collections/index.d.ts +10 -0
  26. package/dist/collections/index.js +6 -0
  27. package/dist/collections/mdx/loader-webpack.d.ts +17 -0
  28. package/dist/collections/mdx/loader-webpack.js +38 -0
  29. package/dist/collections/mdx/runtime-browser.d.ts +44 -0
  30. package/dist/collections/mdx/runtime-browser.js +74 -0
  31. package/dist/collections/mdx/runtime-dynamic.d.ts +42 -0
  32. package/dist/collections/mdx/runtime-dynamic.js +94 -0
  33. package/dist/collections/mdx/runtime.d.ts +69 -0
  34. package/dist/collections/mdx/runtime.js +45 -0
  35. package/dist/collections/mdx.d.ts +10 -0
  36. package/dist/collections/mdx.js +287 -0
  37. package/dist/collections/meta/loader-webpack.d.ts +17 -0
  38. package/dist/collections/meta/loader-webpack.js +41 -0
  39. package/dist/collections/meta/runtime.d.ts +19 -0
  40. package/dist/collections/meta/runtime.js +18 -0
  41. package/dist/collections/meta.d.ts +10 -0
  42. package/dist/collections/meta.js +166 -0
  43. package/dist/collections/runtime/file-store.d.ts +19 -0
  44. package/dist/collections/runtime/file-store.js +7 -0
  45. package/dist/collections/runtime/store.d.ts +28 -0
  46. package/dist/collections/runtime/store.js +6 -0
  47. package/dist/config/index.d.ts +10 -0
  48. package/dist/config/index.js +7 -0
  49. package/dist/core-DxnSmTRe.d.ts +411 -0
  50. package/dist/index.d.ts +13 -31
  51. package/dist/index.js +0 -51
  52. package/dist/load-from-file-MLL4WQ5J.js +7 -0
  53. package/dist/loader-T756NSCS.js +7 -0
  54. package/dist/loader-VGDLYG4T.js +7 -0
  55. package/dist/next/index.cjs +571 -0
  56. package/dist/next/index.d.ts +27 -0
  57. package/dist/next/index.js +99 -0
  58. package/dist/node/loader.d.ts +5 -0
  59. package/dist/node/loader.js +46 -0
  60. package/dist/node-DCMYL4DL.js +34 -0
  61. package/dist/plugins/git.d.ts +10 -0
  62. package/dist/plugins/git.js +70 -0
  63. package/dist/plugins/json-schema.d.ts +10 -0
  64. package/dist/plugins/json-schema.js +59 -0
  65. package/dist/plugins/with-loader/index.d.ts +61 -0
  66. package/dist/plugins/with-loader/index.js +6 -0
  67. package/dist/plugins/with-loader/webpack.d.ts +27 -0
  68. package/dist/plugins/with-loader/webpack.js +11 -0
  69. package/dist/vite/index.d.ts +33 -0
  70. package/dist/vite/index.js +60 -0
  71. package/dist/vite-QCUPZHHB.js +32 -0
  72. package/package.json +103 -36
  73. package/dist/internal.d.ts +0 -114
  74. package/dist/internal.js +0 -420
@@ -0,0 +1,27 @@
1
+ import { NextConfig } from 'next';
2
+ import { a as Core } from '../core-DxnSmTRe.js';
3
+ import 'chokidar';
4
+ import '@mdx-js/mdx';
5
+ import 'vfile';
6
+ import '@standard-schema/spec';
7
+ import 'unified';
8
+ import 'mdast';
9
+ import 'vite';
10
+ import 'node:module';
11
+
12
+ interface NextOptions {
13
+ /**
14
+ * Path to source configuration file
15
+ */
16
+ configPath?: string;
17
+ /**
18
+ * Directory for output files
19
+ *
20
+ * @defaultValue '.content'
21
+ */
22
+ outDir?: string;
23
+ }
24
+ declare function createContent(nextOptions?: NextOptions): Promise<(nextConfig?: NextConfig) => NextConfig>;
25
+ declare function createStandaloneCore(options: NextOptions): Promise<Core>;
26
+
27
+ export { type NextOptions, createContent, createStandaloneCore };
@@ -0,0 +1,99 @@
1
+ import {
2
+ loadConfig
3
+ } from "../chunk-M72VQL5M.js";
4
+ import "../chunk-IGLM4N4P.js";
5
+ import {
6
+ Core
7
+ } from "../chunk-Z7KHD7MS.js";
8
+ import "../chunk-6XDQG2GV.js";
9
+
10
+ // src/next/index.ts
11
+ import * as path from "path";
12
+ async function createContent(nextOptions = {}) {
13
+ const core = createNextCore(applyDefaults(nextOptions));
14
+ await core.init({
15
+ config: loadConfig(core, true)
16
+ });
17
+ if (process.env._FUMADOCS_MDX !== "1") {
18
+ process.env._FUMADOCS_MDX = "1";
19
+ await core.emit({ write: true });
20
+ await init(process.env.NODE_ENV === "development", core);
21
+ }
22
+ return (nextConfig = {}) => {
23
+ const ctx = core.getPluginContext();
24
+ for (const plugin of core.getPlugins(true)) {
25
+ nextConfig = plugin.next?.config?.call(ctx, nextConfig) ?? nextConfig;
26
+ }
27
+ return nextConfig;
28
+ };
29
+ }
30
+ async function init(dev, core) {
31
+ if (!dev) return;
32
+ const { FSWatcher } = await import("chokidar");
33
+ const { configPath, outDir } = core.getOptions();
34
+ const absoluteConfigPath = path.resolve(configPath);
35
+ let watcher;
36
+ async function devServer() {
37
+ if (watcher && !watcher.closed) {
38
+ await watcher.close();
39
+ }
40
+ watcher = new FSWatcher({
41
+ ignoreInitial: true,
42
+ persistent: true,
43
+ ignored: [outDir]
44
+ });
45
+ watcher.add(configPath);
46
+ for (const collection of core.getCollections(true)) {
47
+ const handler = collection.handlers.fs;
48
+ if (handler) {
49
+ watcher.add(handler.dir);
50
+ }
51
+ }
52
+ watcher.once("ready", () => {
53
+ console.log("[MDX] started dev server");
54
+ });
55
+ watcher.on("all", (_event, file) => {
56
+ if (path.resolve(file) === absoluteConfigPath) {
57
+ console.log("[MDX] restarting dev server");
58
+ watcher?.removeAllListeners();
59
+ void (async () => {
60
+ await core.init({
61
+ config: loadConfig(core, true)
62
+ });
63
+ await devServer();
64
+ await core.emit({ write: true });
65
+ })();
66
+ }
67
+ });
68
+ await core.initServer({ watcher });
69
+ }
70
+ process.on("exit", () => {
71
+ if (!watcher || watcher.closed) return;
72
+ console.log("[MDX] closing dev server");
73
+ void watcher.close();
74
+ });
75
+ await devServer();
76
+ }
77
+ async function createStandaloneCore(options) {
78
+ const core = createNextCore(applyDefaults(options));
79
+ await core.init({
80
+ config: loadConfig(core, true)
81
+ });
82
+ return core;
83
+ }
84
+ function applyDefaults(options) {
85
+ return {
86
+ outDir: options.outDir ?? Core.defaultOptions.outDir,
87
+ configPath: options.configPath ?? Core.defaultOptions.configPath
88
+ };
89
+ }
90
+ function createNextCore(options) {
91
+ return new Core({
92
+ outDir: options.outDir,
93
+ configPath: options.configPath
94
+ });
95
+ }
96
+ export {
97
+ createContent,
98
+ createStandaloneCore
99
+ };
@@ -0,0 +1,5 @@
1
+ import { LoadHook } from 'node:module';
2
+
3
+ declare const load: LoadHook;
4
+
5
+ export { load };
@@ -0,0 +1,46 @@
1
+ import {
2
+ createDynamicCore
3
+ } from "../chunk-LDBQ66H3.js";
4
+ import {
5
+ Core
6
+ } from "../chunk-Z7KHD7MS.js";
7
+ import {
8
+ createCache
9
+ } from "../chunk-6XDQG2GV.js";
10
+
11
+ // src/node/loader.ts
12
+ var configLoader = createDynamicCore({
13
+ core: new Core({
14
+ configPath: Core.defaultOptions.configPath,
15
+ outDir: Core.defaultOptions.outDir
16
+ }),
17
+ buildConfig: true,
18
+ mode: "production"
19
+ });
20
+ var load = async (url, context, nextLoad) => {
21
+ const core = await configLoader.getCore();
22
+ const store = createCache(core.cache);
23
+ const hooks = await store.cached("node:load-hooks", async () => {
24
+ const ctx = core.getPluginContext();
25
+ const hooks2 = await Promise.all(
26
+ core.getPlugins(true).map(async (plugin) => {
27
+ return plugin.node?.createLoad?.call(ctx);
28
+ })
29
+ );
30
+ return hooks2.filter((v) => v !== void 0);
31
+ });
32
+ function run(i, url2, context2) {
33
+ if (i >= hooks.length) {
34
+ return nextLoad(url2, context2);
35
+ }
36
+ return hooks[i](
37
+ url2,
38
+ context2,
39
+ (url3, ctx) => run(i + 1, url3, { ...context2, ...ctx })
40
+ );
41
+ }
42
+ return run(0, url, context);
43
+ };
44
+ export {
45
+ load
46
+ };
@@ -0,0 +1,34 @@
1
+ // src/plugins/with-loader/node.ts
2
+ import { fileURLToPath } from "url";
3
+ import fs from "fs/promises";
4
+ function toNode(test, loader) {
5
+ return async (url, _context, nextLoad) => {
6
+ if (url.startsWith("file:///") && (!test || test.test(url))) {
7
+ const parsedUrl = new URL(url);
8
+ const filePath = fileURLToPath(parsedUrl);
9
+ const result = await loader.load({
10
+ filePath,
11
+ query: Object.fromEntries(parsedUrl.searchParams.entries()),
12
+ async getSource() {
13
+ return (await fs.readFile(filePath)).toString();
14
+ },
15
+ development: false,
16
+ compiler: {
17
+ addDependency() {
18
+ }
19
+ }
20
+ });
21
+ if (result) {
22
+ return {
23
+ source: result.code,
24
+ format: "module",
25
+ shortCircuit: true
26
+ };
27
+ }
28
+ }
29
+ return nextLoad(url);
30
+ };
31
+ }
32
+ export {
33
+ toNode
34
+ };
@@ -0,0 +1,10 @@
1
+ export { w as GitPluginOptions, x as VersionControlClient, V as VersionControlFileData, v as VersionControlHandler, u as default } from '../core-DxnSmTRe.js';
2
+ import 'chokidar';
3
+ import '@mdx-js/mdx';
4
+ import 'vfile';
5
+ import '@standard-schema/spec';
6
+ import 'unified';
7
+ import 'mdast';
8
+ import 'vite';
9
+ import 'next';
10
+ import 'node:module';
@@ -0,0 +1,70 @@
1
+ import {
2
+ createCache
3
+ } from "../chunk-6XDQG2GV.js";
4
+
5
+ // src/plugins/git.ts
6
+ import path from "path";
7
+ import { x } from "tinyexec";
8
+ function git(options = {}) {
9
+ const { filter = () => true } = options;
10
+ let client;
11
+ return {
12
+ name: "git",
13
+ config() {
14
+ const { workspace } = this.core.getOptions();
15
+ const cwd = workspace ? path.resolve(workspace.dir) : process.cwd();
16
+ client = createGitClient(cwd);
17
+ },
18
+ collection(collection) {
19
+ if (!filter(collection.name)) return;
20
+ const handler = collection.handlers["version-control"];
21
+ if (!handler) return;
22
+ return handler.client({ client });
23
+ }
24
+ };
25
+ }
26
+ function createGitClient(cwd) {
27
+ const cache = createCache();
28
+ function mapDate(out) {
29
+ if (out.exitCode !== 0) return null;
30
+ const date = new Date(out.stdout);
31
+ return Number.isNaN(date.getTime()) ? null : date;
32
+ }
33
+ return {
34
+ async getFileData({ filePath }) {
35
+ return cache.cached(filePath, async () => {
36
+ const relativePath = path.relative(cwd, filePath);
37
+ const [mod, create] = await Promise.all([
38
+ x("git", ["log", "-1", "--pretty=%ai", relativePath], {
39
+ nodeOptions: {
40
+ cwd
41
+ }
42
+ }),
43
+ x(
44
+ "git",
45
+ [
46
+ "log",
47
+ "--diff-filter=A",
48
+ "--follow",
49
+ "--format=%ai",
50
+ "-1",
51
+ relativePath
52
+ ],
53
+ {
54
+ nodeOptions: {
55
+ cwd
56
+ }
57
+ }
58
+ )
59
+ ]);
60
+ return {
61
+ lastModified: mapDate(mod),
62
+ creationDate: mapDate(create)
63
+ };
64
+ });
65
+ }
66
+ };
67
+ }
68
+ export {
69
+ git as default
70
+ };
@@ -0,0 +1,10 @@
1
+ export { l as JSONSchemaHandler, J as JSONSchemaOptions, k as default } from '../core-DxnSmTRe.js';
2
+ import 'chokidar';
3
+ import '@mdx-js/mdx';
4
+ import 'vfile';
5
+ import '@standard-schema/spec';
6
+ import 'unified';
7
+ import 'mdast';
8
+ import 'vite';
9
+ import 'next';
10
+ import 'node:module';
@@ -0,0 +1,59 @@
1
+ // src/plugins/json-schema.ts
2
+ import fs from "fs/promises";
3
+ import path from "path";
4
+ function jsonSchema({
5
+ insert = false
6
+ } = {}) {
7
+ function getSchemaPath(name) {
8
+ return `json-schema/${name}.json`;
9
+ }
10
+ return {
11
+ name: "json-schema",
12
+ configureServer(server) {
13
+ const { outDir } = this.core.getOptions();
14
+ if (!server.watcher || !insert) return;
15
+ server.watcher.on("add", async (file) => {
16
+ const match = this.core.getCollections().find((collection) => {
17
+ const handler = collection.handlers.fs;
18
+ if (!handler) return false;
19
+ return handler.hasFile(file);
20
+ });
21
+ if (!match) return;
22
+ let obj;
23
+ try {
24
+ const content = (await fs.readFile(file)).toString();
25
+ obj = content.length > 0 ? JSON.parse(content) : {};
26
+ } catch {
27
+ return;
28
+ }
29
+ if ("$schema" in obj) return;
30
+ const schemaPath = path.join(
31
+ outDir,
32
+ getSchemaPath(parent ? `${parent.name}.meta` : match.name)
33
+ );
34
+ const updated = {
35
+ $schema: path.relative(path.dirname(file), schemaPath),
36
+ ...obj
37
+ };
38
+ await fs.writeFile(file, JSON.stringify(updated, null, 2));
39
+ });
40
+ },
41
+ async emit() {
42
+ const files = [];
43
+ for (const collection of this.core.getCollections()) {
44
+ const handler = collection.handlers["json-schema"];
45
+ if (!handler) continue;
46
+ const jsonSchema2 = await handler.create();
47
+ if (!jsonSchema2) continue;
48
+ files.push({
49
+ path: getSchemaPath(collection.name),
50
+ content: JSON.stringify(jsonSchema2, null, 2)
51
+ });
52
+ }
53
+ return files;
54
+ }
55
+ };
56
+ }
57
+ export {
58
+ jsonSchema as default
59
+ };
@@ -0,0 +1,61 @@
1
+ import { P as PluginContext, d as Plugin } from '../../core-DxnSmTRe.js';
2
+ import 'chokidar';
3
+ import '@mdx-js/mdx';
4
+ import 'vfile';
5
+ import '@standard-schema/spec';
6
+ import 'unified';
7
+ import 'mdast';
8
+ import 'vite';
9
+ import 'next';
10
+ import 'node:module';
11
+
12
+ type Awaitable<T> = T | Promise<T>;
13
+ interface CompilerOptions {
14
+ addDependency: (file: string) => void;
15
+ }
16
+ type LoaderEnvironment = "vite" | "bun" | "node";
17
+ interface Loader {
18
+ /**
19
+ * Transform input into JavaScript.
20
+ *
21
+ * Returns:
22
+ * - `LoaderOutput`: JavaScript code & source map.
23
+ * - `null`: skip the loader. Fallback to default behaviour if possible, otherwise the adapter will try workarounds.
24
+ */
25
+ load: (input: LoaderInput) => Awaitable<LoaderOutput | null>;
26
+ bun?: {
27
+ /**
28
+ * 1. Bun doesn't allow `null` in loaders.
29
+ * 2. Bun requires sync result to support dynamic require().
30
+ */
31
+ load?: (source: string, input: LoaderInput) => Awaitable<Bun.OnLoadResult>;
32
+ };
33
+ }
34
+ interface LoaderInput {
35
+ development: boolean;
36
+ compiler: CompilerOptions;
37
+ filePath: string;
38
+ query: Record<string, string | string[] | undefined>;
39
+ getSource: () => string | Promise<string>;
40
+ }
41
+ interface LoaderOutput {
42
+ code: string;
43
+ map?: unknown;
44
+ }
45
+ interface WithLoaderConfig {
46
+ /**
47
+ * Filter file paths, the input can be either a file URL or file path.
48
+ *
49
+ * Must take resource query into consideration.
50
+ */
51
+ test?: RegExp;
52
+ createLoader: (this: PluginContext, environment: LoaderEnvironment) => Promise<Loader>;
53
+ }
54
+ /**
55
+ * a light layer for implementing loaders.
56
+ *
57
+ * @remarks it doesn't include Next.js, you have to define the webpack/turbopack config, and export the loaders on your own.
58
+ */
59
+ declare function withLoader(plugin: Plugin, { test, createLoader }: WithLoaderConfig): Plugin;
60
+
61
+ export { type CompilerOptions, type Loader, type LoaderInput, type LoaderOutput, type WithLoaderConfig, withLoader };
@@ -0,0 +1,6 @@
1
+ import {
2
+ withLoader
3
+ } from "../../chunk-ERBMAQYP.js";
4
+ export {
5
+ withLoader
6
+ };
@@ -0,0 +1,27 @@
1
+ import { LoaderContext } from 'webpack';
2
+ import { Loader } from './index.js';
3
+ import { a as Core } from '../../core-DxnSmTRe.js';
4
+ import 'chokidar';
5
+ import '@mdx-js/mdx';
6
+ import 'vfile';
7
+ import '@standard-schema/spec';
8
+ import 'unified';
9
+ import 'mdast';
10
+ import 'vite';
11
+ import 'next';
12
+ import 'node:module';
13
+
14
+ type WebpackLoader = (this: LoaderContext<unknown>, source: string, callback: LoaderContext<unknown>["callback"]) => Promise<void>;
15
+ interface WebpackLoaderOptions {
16
+ absoluteCompiledConfigPath: string;
17
+ configPath: string;
18
+ outDir: string;
19
+ isDev: boolean;
20
+ }
21
+ declare function getCore(options: WebpackLoaderOptions): Core;
22
+ /**
23
+ * need to handle the `test` regex in Webpack config instead.
24
+ */
25
+ declare function toWebpack(loader: Loader): WebpackLoader;
26
+
27
+ export { type WebpackLoader, type WebpackLoaderOptions, getCore, toWebpack };
@@ -0,0 +1,11 @@
1
+ import {
2
+ getCore,
3
+ toWebpack
4
+ } from "../../chunk-4RMSJCK2.js";
5
+ import "../../chunk-OUJENWQ4.js";
6
+ import "../../chunk-Z7KHD7MS.js";
7
+ import "../../chunk-6XDQG2GV.js";
8
+ export {
9
+ getCore,
10
+ toWebpack
11
+ };
@@ -0,0 +1,33 @@
1
+ import { PluginOption } from 'vite';
2
+ import { a as Core } from '../core-DxnSmTRe.js';
3
+ import 'chokidar';
4
+ import '@mdx-js/mdx';
5
+ import 'vfile';
6
+ import '@standard-schema/spec';
7
+ import 'unified';
8
+ import 'mdast';
9
+ import 'next';
10
+ import 'node:module';
11
+
12
+ interface PluginOptions {
13
+ /**
14
+ * @defaultValue content.config.ts
15
+ */
16
+ configPath?: string;
17
+ /**
18
+ * Update Vite config to fix module resolution of Fumadocs
19
+ *
20
+ * @defaultValue true
21
+ */
22
+ updateViteConfig?: boolean;
23
+ /**
24
+ * Output directory of generated files
25
+ *
26
+ * @defaultValue '.content'
27
+ */
28
+ outDir?: string;
29
+ }
30
+ declare function content(config: Record<string, unknown>, pluginOptions?: PluginOptions): Promise<PluginOption[]>;
31
+ declare function createStandaloneCore(pluginOptions?: PluginOptions): Promise<Core>;
32
+
33
+ export { type PluginOptions, createStandaloneCore, content as default };
@@ -0,0 +1,60 @@
1
+ import {
2
+ buildConfig
3
+ } from "../chunk-IGLM4N4P.js";
4
+ import {
5
+ Core
6
+ } from "../chunk-Z7KHD7MS.js";
7
+ import "../chunk-6XDQG2GV.js";
8
+
9
+ // src/vite/index.ts
10
+ async function content(config, pluginOptions = {}) {
11
+ const options = applyDefaults(pluginOptions);
12
+ const core = createViteCore(options);
13
+ await core.init({
14
+ config: buildConfig(config)
15
+ });
16
+ const ctx = core.getPluginContext();
17
+ return [
18
+ ...core.getPlugins(true).map((plugin) => plugin.vite?.createPlugin?.call(ctx)),
19
+ {
20
+ name: "fuma-content",
21
+ async buildStart() {
22
+ await core.emit({ write: true });
23
+ },
24
+ async configureServer(server) {
25
+ await core.initServer({
26
+ watcher: server.watcher
27
+ });
28
+ }
29
+ }
30
+ ];
31
+ }
32
+ async function createStandaloneCore(pluginOptions = {}) {
33
+ const { loadConfig } = await import("../load-from-file-MLL4WQ5J.js");
34
+ const core = createViteCore(applyDefaults(pluginOptions));
35
+ await core.init({
36
+ config: loadConfig(core, true)
37
+ });
38
+ return core;
39
+ }
40
+ function createViteCore({ configPath, outDir }) {
41
+ return new Core({
42
+ configPath,
43
+ outDir,
44
+ emit: {
45
+ target: "vite",
46
+ jsExtension: false
47
+ }
48
+ });
49
+ }
50
+ function applyDefaults(options) {
51
+ return {
52
+ updateViteConfig: options.updateViteConfig ?? true,
53
+ configPath: options.configPath ?? Core.defaultOptions.configPath,
54
+ outDir: options.outDir ?? Core.defaultOptions.outDir
55
+ };
56
+ }
57
+ export {
58
+ createStandaloneCore,
59
+ content as default
60
+ };
@@ -0,0 +1,32 @@
1
+ // src/plugins/with-loader/vite.ts
2
+ import { parse } from "querystring";
3
+ function toVite(name, test, loader) {
4
+ return {
5
+ name: `fuma-content:${name}`,
6
+ async transform(value, id) {
7
+ if (test && !test.test(id)) return;
8
+ const [file, query = ""] = id.split("?", 2);
9
+ const result = await loader.load({
10
+ filePath: file,
11
+ query: parse(query),
12
+ getSource() {
13
+ return value;
14
+ },
15
+ development: this.environment.mode === "dev",
16
+ compiler: {
17
+ addDependency: (file2) => {
18
+ this.addWatchFile(file2);
19
+ }
20
+ }
21
+ });
22
+ if (result === null) return null;
23
+ return {
24
+ code: result.code,
25
+ map: result.map
26
+ };
27
+ }
28
+ };
29
+ }
30
+ export {
31
+ toVite
32
+ };