@ecopages/ecopages-jsx 0.2.0-beta.12 → 0.2.0-beta.13
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/package.json +3 -6
- package/src/ecopages-jsx-mdx.d.ts +1 -1
- package/src/ecopages-jsx-mdx.js +1 -1
- package/node_modules/@ecopages/mdx-core/package.json +0 -22
- package/node_modules/@ecopages/mdx-core/src/index.d.ts +0 -2
- package/node_modules/@ecopages/mdx-core/src/index.js +0 -18
- package/node_modules/@ecopages/mdx-core/src/mdx-loader-plugin.d.ts +0 -11
- package/node_modules/@ecopages/mdx-core/src/mdx-loader-plugin.js +0 -44
- package/node_modules/@ecopages/mdx-core/src/mdx-utils.d.ts +0 -29
- package/node_modules/@ecopages/mdx-core/src/mdx-utils.js +0 -55
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecopages/ecopages-jsx",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.13",
|
|
4
4
|
"description": "JSX integration plugin for Ecopages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ecopages",
|
|
@@ -30,16 +30,13 @@
|
|
|
30
30
|
"url": "git+https://github.com/ecopages/ecopages.git",
|
|
31
31
|
"directory": "packages/integrations/ecopages-jsx"
|
|
32
32
|
},
|
|
33
|
-
"bundleDependencies": [
|
|
34
|
-
"@ecopages/mdx-core"
|
|
35
|
-
],
|
|
36
33
|
"dependencies": {
|
|
37
|
-
"@ecopages/mdx
|
|
34
|
+
"@ecopages/mdx": "0.2.0-beta.13",
|
|
38
35
|
"@mdx-js/mdx": "^3.1.1",
|
|
39
36
|
"vfile": "^6.0.3"
|
|
40
37
|
},
|
|
41
38
|
"peerDependencies": {
|
|
42
|
-
"@ecopages/core": "0.2.0-beta.
|
|
39
|
+
"@ecopages/core": "0.2.0-beta.13",
|
|
43
40
|
"@ecopages/jsx": "0.3.0-alpha.25",
|
|
44
41
|
"@ecopages/radiant": "0.3.0-alpha.25"
|
|
45
42
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CompileOptions } from '@mdx-js/mdx';
|
|
2
2
|
import type { EcoComponent, EcoComponentConfig, EcoFunctionComponent, EcoPageFile, GetMetadata } from '@ecopages/core';
|
|
3
3
|
import type { EcoBuildPlugin } from '@ecopages/core/plugins/integration-plugin';
|
|
4
|
-
import { appendMdxExtensions, createMdxExtensionFilter } from '@ecopages/mdx
|
|
4
|
+
import { appendMdxExtensions, createMdxExtensionFilter } from '@ecopages/mdx/core';
|
|
5
5
|
import type { JsxRenderable } from '@ecopages/jsx';
|
|
6
6
|
import type { EcopagesJsxMdxCompileOptions, EcopagesJsxMdxOptions } from './ecopages-jsx.types.js';
|
|
7
7
|
export type ResolvedMdxCompileOptions = EcopagesJsxMdxCompileOptions & Pick<CompileOptions, 'jsxImportSource' | 'jsxRuntime'>;
|
package/src/ecopages-jsx-mdx.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
createMdxExtensionFilter,
|
|
6
6
|
createMdxLoaderPlugin as createMdxLoaderPluginCore,
|
|
7
7
|
resolveMdxCompilerOptions as resolveMdxCompilerOptionsCore
|
|
8
|
-
} from "@ecopages/mdx
|
|
8
|
+
} from "@ecopages/mdx/core";
|
|
9
9
|
import { VFile } from "vfile";
|
|
10
10
|
import { ECOPAGES_JSX_PLUGIN_NAME } from "./ecopages-jsx.constants.js";
|
|
11
11
|
const resolveMdxCompilerOptions = (mdxOptions) => resolveMdxCompilerOptionsCore(mdxOptions, {
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@ecopages/mdx-core",
|
|
3
|
-
"version": "0.2.0-beta.12",
|
|
4
|
-
"description": "Shared MDX loader utilities for Ecopages integrations",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"default": "./src/index.js",
|
|
10
|
-
"types": "./src/index.d.ts"
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
"peerDependencies": {
|
|
14
|
-
"@ecopages/core": "0.2.0-beta.12",
|
|
15
|
-
"@mdx-js/mdx": "^3.1.0"
|
|
16
|
-
},
|
|
17
|
-
"dependencies": {
|
|
18
|
-
"source-map": "^0.7.6",
|
|
19
|
-
"vfile": "^6.0.3"
|
|
20
|
-
},
|
|
21
|
-
"types": "./src/index.d.ts"
|
|
22
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export { createMdxLoaderPlugin, type CreateMdxLoaderPluginOptions } from './mdx-loader-plugin.js';
|
|
2
|
-
export { appendMdxExtensions, createMdxExtensionFilter, mergePluginLists, resolveCompileFormat, resolveLoaderExtensions, resolveMdxCompilerOptions, type MdxCompilerOptionsInput, } from './mdx-utils.js';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { createMdxLoaderPlugin } from "./mdx-loader-plugin.js";
|
|
2
|
-
import {
|
|
3
|
-
appendMdxExtensions,
|
|
4
|
-
createMdxExtensionFilter,
|
|
5
|
-
mergePluginLists,
|
|
6
|
-
resolveCompileFormat,
|
|
7
|
-
resolveLoaderExtensions,
|
|
8
|
-
resolveMdxCompilerOptions
|
|
9
|
-
} from "./mdx-utils.js";
|
|
10
|
-
export {
|
|
11
|
-
appendMdxExtensions,
|
|
12
|
-
createMdxExtensionFilter,
|
|
13
|
-
createMdxLoaderPlugin,
|
|
14
|
-
mergePluginLists,
|
|
15
|
-
resolveCompileFormat,
|
|
16
|
-
resolveLoaderExtensions,
|
|
17
|
-
resolveMdxCompilerOptions
|
|
18
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { EcoBuildPlugin } from '@ecopages/core/plugins/integration-plugin';
|
|
2
|
-
import { type CompileOptions } from '@mdx-js/mdx';
|
|
3
|
-
export interface CreateMdxLoaderPluginOptions {
|
|
4
|
-
name: string;
|
|
5
|
-
compilerOptions?: CompileOptions;
|
|
6
|
-
extensions?: string[];
|
|
7
|
-
defaultMdExtensions?: string[];
|
|
8
|
-
includeSourceMap?: boolean;
|
|
9
|
-
loader?: 'js' | 'jsx';
|
|
10
|
-
}
|
|
11
|
-
export declare function createMdxLoaderPlugin(options: CreateMdxLoaderPluginOptions): EcoBuildPlugin;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { readFile } from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { compile } from "@mdx-js/mdx";
|
|
4
|
-
import sourceMap from "source-map";
|
|
5
|
-
import { VFile } from "vfile";
|
|
6
|
-
import { createMdxExtensionFilter, resolveCompileFormat, resolveLoaderExtensions } from "./mdx-utils.js";
|
|
7
|
-
function createMdxLoaderPlugin(options) {
|
|
8
|
-
const {
|
|
9
|
-
name,
|
|
10
|
-
compilerOptions,
|
|
11
|
-
extensions = resolveLoaderExtensions(compilerOptions, {
|
|
12
|
-
defaultMdExtensions: options.defaultMdExtensions
|
|
13
|
-
}),
|
|
14
|
-
includeSourceMap = true,
|
|
15
|
-
loader = compilerOptions?.jsx ? "jsx" : "js"
|
|
16
|
-
} = options;
|
|
17
|
-
const filter = createMdxExtensionFilter(extensions, { allowQueryString: true });
|
|
18
|
-
return {
|
|
19
|
-
name,
|
|
20
|
-
setup(build) {
|
|
21
|
-
build.onLoad({ filter }, async (args) => {
|
|
22
|
-
const filePath = args.path.includes("?") ? args.path.split("?")[0] : args.path;
|
|
23
|
-
const source = await readFile(filePath, "utf-8");
|
|
24
|
-
const file = new VFile({ path: filePath, value: source });
|
|
25
|
-
const compiled = await compile(file, {
|
|
26
|
-
...compilerOptions,
|
|
27
|
-
format: resolveCompileFormat(filePath, compilerOptions),
|
|
28
|
-
SourceMapGenerator: sourceMap.SourceMapGenerator
|
|
29
|
-
});
|
|
30
|
-
const inlineSourceMap = includeSourceMap && compiled.map ? `
|
|
31
|
-
//# sourceMappingURL=data:application/json;base64,${Buffer.from(JSON.stringify(compiled.map)).toString("base64")}
|
|
32
|
-
` : "";
|
|
33
|
-
return {
|
|
34
|
-
contents: `${String(compiled.value)}${inlineSourceMap}`,
|
|
35
|
-
loader,
|
|
36
|
-
resolveDir: path.dirname(args.path)
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
export {
|
|
43
|
-
createMdxLoaderPlugin
|
|
44
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { CompileOptions } from '@mdx-js/mdx';
|
|
2
|
-
export interface MdxCompilerOptionsInput {
|
|
3
|
-
compilerOptions?: CompileOptions;
|
|
4
|
-
remarkPlugins?: CompileOptions['remarkPlugins'];
|
|
5
|
-
rehypePlugins?: CompileOptions['rehypePlugins'];
|
|
6
|
-
recmaPlugins?: CompileOptions['recmaPlugins'];
|
|
7
|
-
}
|
|
8
|
-
export declare const mergePluginLists: <T>(...lists: Array<readonly T[] | null | undefined>) => T[] | undefined;
|
|
9
|
-
export declare const appendMdxExtensions: (target: string[], mdxExtensions: string[]) => void;
|
|
10
|
-
export declare const createMdxExtensionFilter: (extensions: string[], options?: {
|
|
11
|
-
allowQueryString?: boolean;
|
|
12
|
-
}) => RegExp;
|
|
13
|
-
export declare function resolveLoaderExtensions(compilerOptions?: CompileOptions, options?: {
|
|
14
|
-
defaultMdExtensions?: string[];
|
|
15
|
-
}): string[];
|
|
16
|
-
/**
|
|
17
|
-
* Resolves the MDX parser mode for a source file.
|
|
18
|
-
*
|
|
19
|
-
* Files with a `.md` extension must be forced into `mdx` mode when the caller
|
|
20
|
-
* explicitly opts them into the MDX pipeline. Leaving the compiler in `detect`
|
|
21
|
-
* mode would treat `.md` files as plain markdown, causing top-level ESM such as
|
|
22
|
-
* `import` and `export` to render as text instead of being compiled.
|
|
23
|
-
*/
|
|
24
|
-
export declare function resolveCompileFormat(filePath: string, compilerOptions?: CompileOptions): CompileOptions['format'];
|
|
25
|
-
export declare function resolveMdxCompilerOptions(mdxOptions: MdxCompilerOptionsInput, options: {
|
|
26
|
-
jsxImportSource: string;
|
|
27
|
-
jsxRuntime?: CompileOptions['jsxRuntime'];
|
|
28
|
-
defaults?: CompileOptions;
|
|
29
|
-
}): CompileOptions;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
const mergePluginLists = (...lists) => {
|
|
3
|
-
const merged = lists.flatMap((list) => list ? [...list] : []);
|
|
4
|
-
return merged.length > 0 ? merged : void 0;
|
|
5
|
-
};
|
|
6
|
-
const appendMdxExtensions = (target, mdxExtensions) => {
|
|
7
|
-
for (const extension of mdxExtensions) {
|
|
8
|
-
if (!target.includes(extension)) {
|
|
9
|
-
target.push(extension);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
const escapeRegex = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
14
|
-
const createMdxExtensionFilter = (extensions, options) => {
|
|
15
|
-
const escaped = extensions.map(escapeRegex);
|
|
16
|
-
const suffix = options?.allowQueryString ? "(\\?.*)?$" : "$";
|
|
17
|
-
return new RegExp(`(${escaped.join("|")})${suffix}`);
|
|
18
|
-
};
|
|
19
|
-
function resolveLoaderExtensions(compilerOptions, options) {
|
|
20
|
-
const mdxExtensions = compilerOptions?.mdxExtensions ?? [".mdx"];
|
|
21
|
-
const mdExtensions = compilerOptions?.mdExtensions ?? options?.defaultMdExtensions ?? [];
|
|
22
|
-
return [...mdxExtensions, ...mdExtensions];
|
|
23
|
-
}
|
|
24
|
-
function resolveCompileFormat(filePath, compilerOptions) {
|
|
25
|
-
const configuredFormat = compilerOptions?.format;
|
|
26
|
-
if (configuredFormat && configuredFormat !== "detect") {
|
|
27
|
-
return configuredFormat;
|
|
28
|
-
}
|
|
29
|
-
return path.extname(filePath).toLowerCase() === ".md" ? "mdx" : configuredFormat;
|
|
30
|
-
}
|
|
31
|
-
function resolveMdxCompilerOptions(mdxOptions, options) {
|
|
32
|
-
const { compilerOptions, remarkPlugins, rehypePlugins, recmaPlugins } = mdxOptions;
|
|
33
|
-
const resolved = {
|
|
34
|
-
...options.defaults,
|
|
35
|
-
...compilerOptions,
|
|
36
|
-
jsxImportSource: options.jsxImportSource,
|
|
37
|
-
jsxRuntime: options.jsxRuntime ?? "automatic",
|
|
38
|
-
development: process.env.NODE_ENV === "development"
|
|
39
|
-
};
|
|
40
|
-
const mergedRemark = mergePluginLists(compilerOptions?.remarkPlugins, remarkPlugins);
|
|
41
|
-
const mergedRehype = mergePluginLists(compilerOptions?.rehypePlugins, rehypePlugins);
|
|
42
|
-
const mergedRecma = mergePluginLists(compilerOptions?.recmaPlugins, recmaPlugins);
|
|
43
|
-
if (mergedRemark) resolved.remarkPlugins = mergedRemark;
|
|
44
|
-
if (mergedRehype) resolved.rehypePlugins = mergedRehype;
|
|
45
|
-
if (mergedRecma) resolved.recmaPlugins = mergedRecma;
|
|
46
|
-
return resolved;
|
|
47
|
-
}
|
|
48
|
-
export {
|
|
49
|
-
appendMdxExtensions,
|
|
50
|
-
createMdxExtensionFilter,
|
|
51
|
-
mergePluginLists,
|
|
52
|
-
resolveCompileFormat,
|
|
53
|
-
resolveLoaderExtensions,
|
|
54
|
-
resolveMdxCompilerOptions
|
|
55
|
-
};
|