@teambit/mdx 1.0.413 → 1.0.414
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/artifacts/env-template/public/314.3776669ccd7cd7f3b7a8.js +690 -0
- package/artifacts/env-template/public/453.042e4d7752cf6b24cd7e.js +41 -0
- package/artifacts/env-template/public/769.df90c4d201536c9ea25a.js +232 -0
- package/artifacts/env-template/public/871.9a7e9061377f8f261632.js +257 -0
- package/artifacts/env-template/public/assets-manifest.json +58 -0
- package/artifacts/env-template/public/compositions.bab12a607ad1b8272ce9.js +1 -0
- package/artifacts/env-template/public/compositions.html +2 -0
- package/artifacts/env-template/public/overview.b7d784140c8f88d67928.js +1 -0
- package/artifacts/env-template/public/overview.html +2 -0
- package/artifacts/env-template/public/peers.eb976477c74fd8780ae6.js +1 -0
- package/artifacts/env-template/public/preview-root.2182a25a76a310169ca9.js +1 -0
- package/artifacts/env-template/public/static/css/314.3571d7f7.css +1 -0
- package/artifacts/env-template/public/static/css/compositions.7f2d907d.css +1 -0
- package/artifacts/env-template/public/static/css/preview-root.ebd38a13.css +1 -0
- package/dist/{preview-1727148128138.js → preview-1727262607766.js} +2 -2
- package/package.json +18 -18
- package/index.ts +0 -8
- package/mdx.aspect.ts +0 -7
- package/mdx.compiler.ts +0 -137
- package/mdx.detector.spec.ts +0 -26
- package/mdx.detector.ts +0 -21
- package/mdx.doc-reader.ts +0 -18
- package/mdx.env.ts +0 -7
- package/mdx.main.runtime.ts +0 -142
- package/mdx.templates.ts +0 -13
- /package/{compositions-1727148128138.js → compositions-1727262607766.js} +0 -0
- /package/{overview-1727148128138.js → overview-1727262607766.js} +0 -0
package/mdx.detector.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { DependencyDetector, FileContext } from '@teambit/dependency-resolver';
|
|
2
|
-
import { compileSync } from '@teambit/mdx.compilers.mdx-transpiler';
|
|
3
|
-
|
|
4
|
-
export class MDXDependencyDetector implements DependencyDetector {
|
|
5
|
-
constructor(private supportedExtensions: string[]) {}
|
|
6
|
-
|
|
7
|
-
isSupported(context: FileContext): boolean {
|
|
8
|
-
return this.supportedExtensions.includes(context.ext);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
detect(source: string): string[] {
|
|
12
|
-
const output = compileSync(source);
|
|
13
|
-
const imports = output.getImportSpecifiers();
|
|
14
|
-
if (!imports) return [];
|
|
15
|
-
const files: string[] = imports.map((importSpec) => {
|
|
16
|
-
return importSpec.fromModule;
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
return files;
|
|
20
|
-
}
|
|
21
|
-
}
|
package/mdx.doc-reader.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { DocReader, Doc } from '@teambit/docs';
|
|
2
|
-
import { compile } from '@teambit/mdx.compilers.mdx-transpiler';
|
|
3
|
-
|
|
4
|
-
export class MDXDocReader implements DocReader {
|
|
5
|
-
constructor(private extensions: string[]) {}
|
|
6
|
-
|
|
7
|
-
async read(path: string, contents: Buffer) {
|
|
8
|
-
const output = await compile(contents.toString('utf-8'), { filepath: path });
|
|
9
|
-
const metadata = output.getMetadata();
|
|
10
|
-
|
|
11
|
-
const doc = Doc.from(path, metadata);
|
|
12
|
-
return doc;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
isFormatSupported(format: string) {
|
|
16
|
-
return this.extensions.includes(format);
|
|
17
|
-
}
|
|
18
|
-
}
|
package/mdx.env.ts
DELETED
package/mdx.main.runtime.ts
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { Harmony } from '@teambit/harmony';
|
|
2
|
-
import { BabelCompiler } from '@teambit/compilation.babel-compiler';
|
|
3
|
-
import { TypescriptConfigMutator } from '@teambit/typescript.modules.ts-config-mutator';
|
|
4
|
-
import { TsConfigTransformer } from '@teambit/typescript';
|
|
5
|
-
import { MainRuntime } from '@teambit/cli';
|
|
6
|
-
import { CompilerAspect, CompilerMain } from '@teambit/compiler';
|
|
7
|
-
import { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';
|
|
8
|
-
import { DocsAspect, DocsMain } from '@teambit/docs';
|
|
9
|
-
import { ComponentID } from '@teambit/component-id';
|
|
10
|
-
import { LoggerAspect, LoggerMain } from '@teambit/logger';
|
|
11
|
-
import { WorkerAspect, WorkerMain } from '@teambit/worker';
|
|
12
|
-
import { EnvContext, EnvsAspect, EnvsMain } from '@teambit/envs';
|
|
13
|
-
import { MultiCompilerAspect, MultiCompilerMain } from '@teambit/multi-compiler';
|
|
14
|
-
import { ReactAspect, ReactEnv, ReactMain } from '@teambit/react';
|
|
15
|
-
import { GeneratorAspect, GeneratorMain } from '@teambit/generator';
|
|
16
|
-
import { MDXAspect } from './mdx.aspect';
|
|
17
|
-
import { MDXCompiler, MDXCompilerOpts } from './mdx.compiler';
|
|
18
|
-
import { MDXDependencyDetector } from './mdx.detector';
|
|
19
|
-
import { MDXDocReader } from './mdx.doc-reader';
|
|
20
|
-
import { getTemplates } from './mdx.templates';
|
|
21
|
-
import { babelConfig } from './babel/babel.config';
|
|
22
|
-
|
|
23
|
-
export type MDXConfig = {
|
|
24
|
-
/**
|
|
25
|
-
* list of file extensions to consider as MDX files.
|
|
26
|
-
*/
|
|
27
|
-
extensions: string[];
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export class MDXMain {
|
|
31
|
-
icon() {
|
|
32
|
-
return 'https://static.bit.dev/extensions-icons/mdx-icon-small.svg';
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* create an instance of the MDX compiler.
|
|
37
|
-
*/
|
|
38
|
-
createCompiler(opts: MDXCompilerOpts = {}) {
|
|
39
|
-
const mdxCompiler = new MDXCompiler(MDXAspect.id, opts);
|
|
40
|
-
return mdxCompiler;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
_mdxEnv: ReactEnv;
|
|
44
|
-
get mdxEnv() {
|
|
45
|
-
return this._mdxEnv;
|
|
46
|
-
}
|
|
47
|
-
private set mdxEnv(value: ReactEnv) {
|
|
48
|
-
this._mdxEnv = value;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
static runtime = MainRuntime;
|
|
52
|
-
|
|
53
|
-
static dependencies = [
|
|
54
|
-
DocsAspect,
|
|
55
|
-
DependencyResolverAspect,
|
|
56
|
-
ReactAspect,
|
|
57
|
-
EnvsAspect,
|
|
58
|
-
MultiCompilerAspect,
|
|
59
|
-
CompilerAspect,
|
|
60
|
-
GeneratorAspect,
|
|
61
|
-
LoggerAspect,
|
|
62
|
-
WorkerAspect,
|
|
63
|
-
];
|
|
64
|
-
|
|
65
|
-
static defaultConfig = {
|
|
66
|
-
extensions: ['.md', '.mdx'],
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
static async provider(
|
|
70
|
-
[docs, depResolver, react, envs, multiCompiler, compiler, generator, loggerAspect, workerMain]: [
|
|
71
|
-
DocsMain,
|
|
72
|
-
DependencyResolverMain,
|
|
73
|
-
ReactMain,
|
|
74
|
-
EnvsMain,
|
|
75
|
-
MultiCompilerMain,
|
|
76
|
-
CompilerMain,
|
|
77
|
-
GeneratorMain,
|
|
78
|
-
LoggerMain,
|
|
79
|
-
WorkerMain
|
|
80
|
-
],
|
|
81
|
-
config: MDXConfig,
|
|
82
|
-
slots,
|
|
83
|
-
harmony: Harmony
|
|
84
|
-
) {
|
|
85
|
-
const mdx = new MDXMain();
|
|
86
|
-
const tsTransformer: TsConfigTransformer = (tsconfig: TypescriptConfigMutator) => {
|
|
87
|
-
// set the shouldCopyNonSupportedFiles to false since we don't want ts to copy the .mdx file to the dist folder (it will conflict with the .mdx.js file created by the mdx compiler)
|
|
88
|
-
tsconfig.setCompileJs(false).setCompileJsx(false).setShouldCopyNonSupportedFiles(false);
|
|
89
|
-
return tsconfig;
|
|
90
|
-
};
|
|
91
|
-
const tsCompiler = react.env.getCompiler([tsTransformer]);
|
|
92
|
-
const logger = loggerAspect.createLogger(MDXAspect.id);
|
|
93
|
-
|
|
94
|
-
const babelCompiler = BabelCompiler.create(
|
|
95
|
-
{
|
|
96
|
-
babelTransformOptions: babelConfig,
|
|
97
|
-
// set the shouldCopyNonSupportedFiles to false since we don't want babel to copy the .mdx file to the dist
|
|
98
|
-
// folder (it will conflict with the .mdx.js file created by the mdx compiler)
|
|
99
|
-
shouldCopyNonSupportedFiles: false,
|
|
100
|
-
},
|
|
101
|
-
{ logger }
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
const mdxCompiler = multiCompiler.createCompiler(
|
|
105
|
-
[
|
|
106
|
-
babelCompiler,
|
|
107
|
-
mdx.createCompiler({ ignoredPatterns: docs.getPatterns(), babelTransformOptions: babelConfig }),
|
|
108
|
-
tsCompiler,
|
|
109
|
-
],
|
|
110
|
-
{}
|
|
111
|
-
);
|
|
112
|
-
const mdxEnv = envs.compose(react.reactEnv, [
|
|
113
|
-
react.overrideCompiler(mdxCompiler),
|
|
114
|
-
react.overrideDependencies({
|
|
115
|
-
dependencies: {
|
|
116
|
-
'@teambit/mdx.ui.mdx-scope-context': '1.0.0',
|
|
117
|
-
'@mdx-js/react': '1.6.22',
|
|
118
|
-
},
|
|
119
|
-
}),
|
|
120
|
-
react.overrideCompilerTasks([compiler.createTask('MDXCompiler', mdxCompiler)]),
|
|
121
|
-
envs.override({
|
|
122
|
-
__getDescriptor: async () => {
|
|
123
|
-
return {
|
|
124
|
-
type: 'mdx',
|
|
125
|
-
};
|
|
126
|
-
},
|
|
127
|
-
}),
|
|
128
|
-
]);
|
|
129
|
-
envs.registerEnv(mdxEnv);
|
|
130
|
-
depResolver.registerDetector(new MDXDependencyDetector(config.extensions));
|
|
131
|
-
docs.registerDocReader(new MDXDocReader(config.extensions));
|
|
132
|
-
if (generator) {
|
|
133
|
-
const envContext = new EnvContext(ComponentID.fromString(ReactAspect.id), loggerAspect, workerMain, harmony);
|
|
134
|
-
generator.registerComponentTemplate(getTemplates(envContext));
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
mdx.mdxEnv = mdxEnv as ReactEnv;
|
|
138
|
-
return mdx;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
MDXAspect.addRuntime(MDXMain);
|
package/mdx.templates.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { MdxComponentTemplate, MdxEnvTemplate } from '@teambit/mdx.generator.mdx-templates';
|
|
2
|
-
import { EnvContext } from '@teambit/envs';
|
|
3
|
-
import { ComponentTemplate, TemplateList } from '@teambit/generator';
|
|
4
|
-
|
|
5
|
-
const templateListHandler = TemplateList.from([
|
|
6
|
-
MdxComponentTemplate.from({ env: 'teambit.mdx/mdx-env' }),
|
|
7
|
-
MdxEnvTemplate.from({}),
|
|
8
|
-
]);
|
|
9
|
-
|
|
10
|
-
export function getTemplates(envContext: EnvContext): ComponentTemplate[] {
|
|
11
|
-
const templateList = templateListHandler(envContext);
|
|
12
|
-
return templateList.compute();
|
|
13
|
-
}
|
|
File without changes
|
|
File without changes
|