Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,040 changes: 832 additions & 208 deletions .bitmap

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ commands:
- restore_cache:
key: bitsrc-registry10
- restore_cache:
key: core-aspect-env-v0.0.80-v1
key: core-aspect-env-v0.1.0-v1
- run: npm view @teambit/bit version > ./version.txt
- restore_cache:
key: v3-linux-bvm-folder-{{ checksum "version.txt" }}
Expand Down Expand Up @@ -451,7 +451,7 @@ commands:
- restore_cache:
key: bitsrc-registry10
- restore_cache:
key: core-aspect-env-v0.0.80-v1
key: core-aspect-env-v0.1.0-v1
- run: npm view @teambit/bit version > ./version.txt
- restore_cache:
key: v3-linux-bvm-folder-{{ checksum "version.txt" }}
Expand Down Expand Up @@ -557,7 +557,7 @@ jobs:
name: bbit install
command: cd bit && bbit install
- save_cache:
key: core-aspect-env-v0.0.80-v1
key: core-aspect-env-v0.1.0-v1
paths:
- /home/circleci/Library/Caches/Bit/capsules/caec9a107
# - run: cd bit && bbit compile
Expand Down Expand Up @@ -612,7 +612,7 @@ jobs:
- restore_cache:
key: bitsrc-registry10
- restore_cache:
key: core-aspect-env-v0.0.80-v1
key: core-aspect-env-v0.1.0-v1
- run:
name: 'check circular dependencies'
command: 'cd bit && ./scripts/circular-deps-check/ci-check.sh'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
"packageManager": "teambit.dependencies/pnpm",
"policy": {
"dependencies": {
"@teambit/mdx.ui.mdx-scope-context": "1.0.0",
"@teambit/react.react-env": "1.0.77",
"@teambit/typescript.typescript-compiler": "2.0.38"
"@teambit/mdx.ui.mdx-scope-context": "1.0.7",
"@teambit/react.react-env": "1.1.0",
"@teambit/typescript.typescript-compiler": "2.0.64"
},
"peerDependencies": {}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const ARTIFACTS_QUERY = gql`
}
}
}
`;
` as any;

export function useComponentArtifacts(
host: string,
Expand Down Expand Up @@ -85,7 +85,7 @@ const ARTIFACTS_QUERY_WITH_FILE_CONTENT = gql`
}
}
}
`;
` as any;

export function useComponentArtifactFileContent(
host: string,
Expand Down
64,132 changes: 25,608 additions & 38,524 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scopes/cloud/hooks/use-cloud-scopes/use-cloud-scopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const GET_CLOUD_SCOPES_QUERY = gql`
displayName
}
}
`;
` as any;

export function useCloudScopes(ids?: string[]): { cloudScopes?: ScopeDescriptor[] } {
const { data } = useDataQuery<{ getCloudScopes?: (ScopeDescriptor & { id: string })[] }>(GET_CLOUD_SCOPES_QUERY, {
Expand Down
2 changes: 1 addition & 1 deletion scopes/cloud/hooks/use-current-user/use-current-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const CURRENT_USER_QUERY = gql`
loginUrl
isLoggedIn
}
`;
` as any;

export function useCurrentUser(): {
currentUser?: CloudUser;
Expand Down
2 changes: 1 addition & 1 deletion scopes/component/component/host/use-component-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const COMPONENT_HOST = gql`
}
}
}
`;
` as any;

export function useComponentHost() {
const { data, loading } = useDataQuery(COMPONENT_HOST);
Expand Down
2 changes: 1 addition & 1 deletion scopes/component/component/ui/aspect-page/aspect-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const GET_COMPONENT = gql`
}
}
}
`;
` as any;

// TODO: get the docs domain from the community aspect and pass it here as a prop
export function AspectPage() {
Expand Down
20 changes: 10 additions & 10 deletions scopes/component/component/ui/use-component.fragments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const componentIdFields = gql`
version
scope
}
`;
` as any;

export const componentOverviewFields = gql`
fragment componentOverviewFields on Component {
Expand Down Expand Up @@ -56,7 +56,7 @@ export const componentOverviewFields = gql`
}
}
${componentIdFields}
`;
` as any;

export const componentFields = gql`
fragment componentFields on Component {
Expand All @@ -72,7 +72,7 @@ export const componentFields = gql`
}
}
${componentOverviewFields}
`;
` as any;

export const componentFieldsWithLogs = gql`
fragment componentFieldWithLogs on Component {
Expand Down Expand Up @@ -100,7 +100,7 @@ export const componentFieldsWithLogs = gql`
}
}
${componentIdFields}
`;
` as any;

export const COMPONENT_QUERY_LOG_FIELDS = `
$logOffset: Int
Expand All @@ -109,7 +109,7 @@ export const COMPONENT_QUERY_LOG_FIELDS = `
$logHead: String
$logSort: String
$logTakeHeadFromComponent: Boolean
`;
` as any;

export const GET_COMPONENT = gql`
query Component($extensionId: String!, $id: String!) {
Expand All @@ -121,7 +121,7 @@ export const GET_COMPONENT = gql`
}
}
${componentFields}
`;
` as any;

export const GET_COMPONENT_WITH_LOGS = gql`
query Component(
Expand All @@ -137,7 +137,7 @@ export const GET_COMPONENT_WITH_LOGS = gql`
}
}
${componentFieldsWithLogs}
`;
` as any;

export const SUB_SUBSCRIPTION_ADDED = gql`
subscription OnComponentAdded {
Expand All @@ -148,7 +148,7 @@ export const SUB_SUBSCRIPTION_ADDED = gql`
}
}
${componentFields}
`;
` as any;

export const SUB_COMPONENT_CHANGED = gql`
subscription OnComponentChanged {
Expand All @@ -159,7 +159,7 @@ export const SUB_COMPONENT_CHANGED = gql`
}
}
${componentFields}
`;
` as any;

export const SUB_COMPONENT_REMOVED = gql`
subscription OnComponentRemoved {
Expand All @@ -170,4 +170,4 @@ export const SUB_COMPONENT_REMOVED = gql`
}
}
${componentIdFields}
`;
` as any;
2 changes: 1 addition & 1 deletion scopes/compositions/model/composition-id/humanize.docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ labels: ['string', 'utility']

import { humanizeCompositionId } from './humanize'

```jsx live=true
```jsx
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of live=true from the code block may affect functionality. The live=true attribute typically indicates that the code should be rendered as an interactive example. Verify that this functionality is still supported in MDX v3, or if an alternative approach is needed to maintain the live code preview feature.

Suggested change
```jsx
```jsx live=true

Copilot uses AI. Check for mistakes.
() => {
return (
<>
Expand Down
6 changes: 3 additions & 3 deletions scopes/harmony/aspect-docs/node/node.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Node environment is composed out of the base [React Environment](https://bit.clo

To use this environment for your components, add it to any of the `variants` in your `workspace.jsonc` file as follows:

```json title="workspace.jsonc"
```json
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The removal of the title attribute from code blocks may reduce documentation clarity. The title="workspace.jsonc" attribute provided helpful context about which file the code example refers to. Consider whether this information should be retained through other means (e.g., comments or surrounding text) to maintain documentation quality.

Suggested change
```json
```json title="workspace.jsonc"

Copilot uses AI. Check for mistakes.
{
"teambit.workspace/variants": {
"some/path": {
Expand Down Expand Up @@ -66,7 +66,7 @@ bit create node-env extensions/custom-node

As with any component, environments must themselves have an environment which compiles, builds, transpiles, etc, them. Bit has a special environment that knows how to create other environments - `teambit.harmony/aspect`. So for any component that is meant to be a Bit environment, you must set `teambit.harmony/aspect` as the environment for that component.

```json title="add variant for the extension and set the aspect env"
```json
{
//...
"teambit.workspace/variants": {
Expand All @@ -83,7 +83,7 @@ Validate the above by running `bit env` and see that the extension-component has

Now that you have a basic customized extension to start from, you can go ahead and configure it for your components in `workspace.json`:

```json title="edit variants and set the new env"
```json
{
//...
"teambit.workspace/variants": {
Expand Down
11 changes: 4 additions & 7 deletions scopes/mdx/mdx/mdx.compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { join } from 'path';
import { outputFileSync } from 'fs-extra';
import type { Compiler, TranspileFileOutput, TranspileFileParams } from '@teambit/compiler';
import type { BuiltTaskResult, BuildContext } from '@teambit/builder';
import { compileSync as mdxCompileSync } from '@teambit/mdx.compilers.mdx-transpiler';
import minimatch from 'minimatch';
import { transpileFileContent as babelTranspileFileContent } from '@teambit/compilation.modules.babel-compiler';
import type { TransformOptions } from '@babel/core';
import { compileSync as mdxCompileSync } from '@mdx-js/mdx';
import { basicMdxOptions } from '@teambit/mdx.modules.mdx-v3-options';

export type MDXCompilerOpts = {
ignoredExtensions?: string[];
Expand Down Expand Up @@ -33,14 +34,10 @@ export class MDXCompiler implements Compiler {
}

transpileFile(fileContent: string, options: TranspileFileParams): TranspileFileOutput {
const afterMdxCompile = mdxCompileSync(fileContent, {
filepath: options.filePath,
// this compiler is not indented to compile according to the bit flavour.
bitFlavour: false,
});
const afterMdxCompile = mdxCompileSync(fileContent, basicMdxOptions);
const filePathAfterMdxCompile = this.replaceFileExtToJs(options.filePath);
const afterBabelCompile = babelTranspileFileContent(
afterMdxCompile.contents,
afterMdxCompile.toString(),
Comment on lines +37 to +40
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MDX v3 compileSync returns a VFile object, not a plain object with a contents property. You should call .toString() method on the result to get the compiled output. However, it appears this is already being done correctly on line 40. Please verify that basicMdxOptions is properly configured for the expected output format.

Copilot uses AI. Check for mistakes.
{
rootDir: options.componentDir,
filePath: filePathAfterMdxCompile,
Expand Down
24 changes: 21 additions & 3 deletions scopes/mdx/mdx/mdx.detector.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
import type { DependencyDetector, FileContext } from '@teambit/dependency-resolver';
import { compileSync } from '@teambit/mdx.compilers.mdx-transpiler';
import { compileSync } from '@mdx-js/mdx';
import { mdxOptions } from '@teambit/mdx.modules.mdx-v3-options';

type ImportSpecifier = {
/**
* relative/absolute or module name. e.g. the `y` in the example of `import x from 'y';`
*/
fromModule: string;

/**
* is default import (e.g. `import x from 'y';`)
*/
isDefault?: boolean;

/**
* the name used to identify the module, e.g. the `x` in the example of `import x from 'y';`
*/
identifier?: string;
};

Comment on lines +4 to 21
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ImportSpecifier type is duplicated from what was likely exported by the old MDX transpiler. Consider importing this type from a shared location or the MDX package if available, rather than redefining it locally. This will reduce maintenance burden and potential drift from the canonical definition.

Suggested change
type ImportSpecifier = {
/**
* relative/absolute or module name. e.g. the `y` in the example of `import x from 'y';`
*/
fromModule: string;
/**
* is default import (e.g. `import x from 'y';`)
*/
isDefault?: boolean;
/**
* the name used to identify the module, e.g. the `x` in the example of `import x from 'y';`
*/
identifier?: string;
};
import type { ImportSpecifier } from '@mdx-js/mdx';

Copilot uses AI. Check for mistakes.
export class MDXDependencyDetector implements DependencyDetector {
constructor(private supportedExtensions: string[]) {}
Expand All @@ -9,8 +27,8 @@ export class MDXDependencyDetector implements DependencyDetector {
}

detect(source: string): string[] {
const output = compileSync(source);
const imports = output.getImportSpecifiers();
const output = compileSync(source, mdxOptions);
const imports = output.data.imports as ImportSpecifier[];
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the doc-reader, accessing output.data.imports without checking if output.data exists could cause runtime errors. Add a null check: const imports = output.data?.imports as ImportSpecifier[] || []; to handle cases where the data property might be undefined.

Suggested change
const imports = output.data.imports as ImportSpecifier[];
const imports = output.data?.imports as ImportSpecifier[] || [];

Copilot uses AI. Check for mistakes.
if (!imports) return [];
Comment on lines +31 to 32
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In MDX v3, the compileSync function returns a VFile object which needs to be converted to a string using .toString() or accessed via .value property. The data.imports property may not exist unless specific plugins are configured to populate it. The expected structure for imports in MDX v3 is different from v1, and without proper plugin configuration, this will likely fail at runtime.

Suggested change
const imports = output.data.imports as ImportSpecifier[];
if (!imports) return [];
const imports = Array.isArray(output.data?.imports) ? output.data.imports as ImportSpecifier[] : [];
if (!imports.length) return [];

Copilot uses AI. Check for mistakes.
const files: string[] = imports.map((importSpec) => {
return importSpec.fromModule;
Expand Down
7 changes: 4 additions & 3 deletions scopes/mdx/mdx/mdx.doc-reader.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import type { DocReader } from '@teambit/docs';
import { Doc } from '@teambit/docs';
import { compile } from '@teambit/mdx.compilers.mdx-transpiler';
import { compileSync } from '@mdx-js/mdx';
import { mdxOptions } from '@teambit/mdx.modules.mdx-v3-options';

export class MDXDocReader implements DocReader {
constructor(private extensions: string[]) {}

async read(path: string, contents: Buffer) {
const output = await compile(contents.toString('utf-8'), { filepath: path });
const metadata = output.getMetadata();
const output = compileSync(contents.toString('utf-8'), mdxOptions);
const metadata = output.data.frontmatter as any;
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code accesses output.data.frontmatter without checking if output.data exists first. MDX v3's compileSync may not always populate the data property, which could lead to a runtime error. Consider adding a null check: const metadata = output.data?.frontmatter as any || {};

Suggested change
const metadata = output.data.frontmatter as any;
const metadata = output.data?.frontmatter as any || {};

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MDX compilation result is cast to as any when accessing the frontmatter data. This loses type safety for the metadata extraction.

Consider defining a proper type interface for the MDX compilation output data structure instead of using as any.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In MDX v3, the compileSync function returns a VFile object, not a plain object with a data.frontmatter property. The frontmatter is typically extracted through remark plugins like remark-frontmatter and remark-mdx-frontmatter. Without proper plugin configuration in mdxOptions, accessing output.data.frontmatter may result in undefined at runtime, breaking the metadata extraction.

Suggested change
const metadata = output.data.frontmatter as any;
// Ensure mdxOptions includes remark-frontmatter and remark-mdx-frontmatter plugins for frontmatter extraction.
const metadata = (output.data && output.data.frontmatter) ? output.data.frontmatter : {};

Copilot uses AI. Check for mistakes.

const doc = Doc.from(path, metadata);
return doc;
Expand Down
8 changes: 5 additions & 3 deletions scopes/react/react/react.env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class ReactEnv
jest: jestModulePath || require.resolve('jest'),
config,
},
{ logger: this.logger, worker }
{ logger: this.logger, worker, devFiles: this.devFiles }
);

return tester;
Expand Down Expand Up @@ -205,7 +205,8 @@ export class ReactEnv
jest: jestModulePath || require.resolve('jest'),
config,
},
{ logger: this.logger, worker }
{ logger: this.logger, worker } as any
// { logger: this.logger, worker, devFiles: this.devFiles },
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented-out code should be removed rather than left in the codebase. The commented line appears to be the correct implementation (including devFiles: this.devFiles), while the active line uses a type assertion (as any) to bypass type checking. Either the commented code should be uncommented and the type issue fixed properly, or it should be removed entirely if it's no longer needed.

Suggested change
{ logger: this.logger, worker } as any
// { logger: this.logger, worker, devFiles: this.devFiles },
{ logger: this.logger, worker, devFiles: this.devFiles }

Copilot uses AI. Check for mistakes.
);
}

Expand Down Expand Up @@ -540,7 +541,8 @@ export class ReactEnv
const worker = this.getJestWorker();
const testerTask = JestTask.create(
{ config: jestConfigPath, jest: jestPath },
{ logger: this.logger, worker, devFiles: this.devFiles }
{ logger: this.logger, worker } as any
// { logger: this.logger, worker, devFiles: this.devFiles },
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented-out code should be removed rather than left in the codebase. The commented line appears to be the correct implementation (including devFiles: this.devFiles), while the active line uses a type assertion (as any) to bypass type checking. Either the commented code should be uncommented and the type issue fixed properly, or it should be removed entirely if it's no longer needed.

Suggested change
{ logger: this.logger, worker } as any
// { logger: this.logger, worker, devFiles: this.devFiles },
{ logger: this.logger, worker, devFiles: this.devFiles },

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to line 209, there's commented-out code with uncertainty about the devFiles parameter. This should be resolved - either include the parameter or remove the commented code completely. Having commented code in production suggests incomplete migration.

Suggested change
// { logger: this.logger, worker, devFiles: this.devFiles },

Copilot uses AI. Check for mistakes.
);
return [this.createCjsCompilerTask(transformers, modifiers?.tsModifier?.module || ts), testerTask];
}
Expand Down
2 changes: 1 addition & 1 deletion scopes/react/react/react.main.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ export class ReactMain {
);
const appType = new ReactAppType('react-app', reactEnv, logger, dependencyResolver);
const react = new ReactMain(reactEnv, envs, application, appType, dependencyResolver, logger);
graphql.register(() => reactSchema(react));
graphql.register(() => reactSchema(react) as any);
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GraphQL schema registration is cast to as any, suppressing type checking. This loses TypeScript's type safety benefits.

Investigate why this type assertion is needed and consider defining proper types for the schema instead of using as any.

Copilot uses AI. Check for mistakes.
envs.registerEnv(reactEnv);
if (generator) {
const envContext = new EnvContext(ComponentID.fromString(ReactAspect.id), loggerMain, workerMain, harmony);
Expand Down
12 changes: 9 additions & 3 deletions scopes/react/react/webpack/webpack.config.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import { postCssConfig } from './postcss.config';
// TODO: remove it once we can set policy from component to component then set it via the component.json
import '@teambit/react.babel.bit-react-transformer';
// Make sure the mdx-loader is a dependency
import '@teambit/mdx.modules.mdx-loader';

// eslint-disable-next-line import/no-unresolved
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The /* eslint-disable import/no-unresolved */ comment suggests there's an unresolved import issue with @mdx-js/loader. This typically indicates that the package is not properly installed or the types are not available. This should be resolved rather than suppressed, as it may cause issues in development and could indicate a missing dependency.

Suggested change
// eslint-disable-next-line import/no-unresolved

Copilot uses AI. Check for mistakes.
import '@mdx-js/loader';
import '@teambit/mdx.modules.mdx-pre-loader';
import { mdxOptions } from '@teambit/mdx.modules.mdx-v3-options';
const styleLoaderPath = require.resolve('style-loader');

const moduleFileExtensions = [
Expand Down Expand Up @@ -157,7 +159,11 @@ export default function (isEnvProduction = false): Configuration {
},
},
{
loader: require.resolve('@teambit/mdx.modules.mdx-loader'),
loader: require.resolve('@mdx-js/loader'),
options: mdxOptions,
},
{
loader: require.resolve('@teambit/mdx.modules.mdx-pre-loader'),
},
Comment on lines +162 to 167
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect loader order for MDX processing

Webpack loaders execute from bottom to top in the use array. The current order has:

  1. @mdx-js/loader (executed second)
  2. @teambit/mdx.modules.mdx-pre-loader (executed first)

This means the pre-loader runs before the main MDX loader, but based on the naming convention, a "pre-loader" should process the file before it's passed to the main loader.

If this is intentional and the pre-loader should run first, consider renaming it to "mdx-post-loader" to clarify the execution order. Otherwise, reverse the order:

{
  loader: require.resolve('@teambit/mdx.modules.mdx-pre-loader'),
},
{
  loader: require.resolve('@mdx-js/loader'),
  options: mdxOptions,
},
Suggested change
loader: require.resolve('@mdx-js/loader'),
options: mdxOptions,
},
{
loader: require.resolve('@teambit/mdx.modules.mdx-pre-loader'),
},
loader: require.resolve('@teambit/mdx.modules.mdx-pre-loader'),
},
{
loader: require.resolve('@mdx-js/loader'),
options: mdxOptions,
},

Copilot uses AI. Check for mistakes.
],
},
Expand Down
7 changes: 6 additions & 1 deletion scopes/react/react/webpack/webpack.config.component.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ComponentID } from '@teambit/component-id';
// TODO: remove it once we can set policy from component to component then set it via the component.json
import '@teambit/react.babel.bit-react-transformer';
import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';
import { mdxOptions } from '@teambit/mdx.modules.mdx-v3-options';

const matchNothingRegex = 'a^';

Expand Down Expand Up @@ -71,7 +72,11 @@ export default function (workDir: string, envId: string): Configuration {
},
},
{
loader: require.resolve('@teambit/mdx.modules.mdx-loader'),
loader: require.resolve('@mdx-js/loader'),
options: mdxOptions,
},
{
loader: require.resolve('@teambit/mdx.modules.mdx-pre-loader'),
},
Comment on lines 74 to 80
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect loader order for MDX processing

Webpack loaders execute from bottom to top in the use array. The current order has:

  1. @mdx-js/loader (executed second)
  2. @teambit/mdx.modules.mdx-pre-loader (executed first)

This means the pre-loader runs before the main MDX loader, but based on the naming convention, a "pre-loader" should process the file before it's passed to the main loader.

If this is intentional and the pre-loader should run first, consider renaming it to "mdx-post-loader" to clarify the execution order. Otherwise, reverse the order:

{
  loader: require.resolve('@teambit/mdx.modules.mdx-pre-loader'),
},
{
  loader: require.resolve('@mdx-js/loader'),
  options: mdxOptions,
},

Copilot uses AI. Check for mistakes.
],
},
Expand Down
Loading