Skip to content

Commit

Permalink
feat: add support for additional entry file extensions (mts, cts) (#4415
Browse files Browse the repository at this point in the history
)
  • Loading branch information
chenjiahan authored Jan 23, 2025
1 parent d996fb0 commit 87e1350
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ export function getDefaultEntry(root: string): RsbuildEntry {
'js',
'tsx',
'jsx',
'mts',
'cts',
'mjs',
'cjs',
].map((ext) => join(root, `src/index.${ext}`));
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/plugins/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const pluginEntry = (): RsbuildPlugin => ({
if (bundlerConfigs.every((config) => !config.entry)) {
throw new Error(
`[rsbuild:config] Could not find any entry module, please make sure that ${color.cyan(
'src/index.(ts|js|tsx|jsx|mjs|cjs)',
'src/index.(ts|js|tsx|jsx|mts|cts|mjs|cjs)',
)} exists, or customize entry through the ${color.cyan(
'source.entry',
)} configuration.`,
Expand Down
4 changes: 2 additions & 2 deletions website/docs/en/config/source/entry.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ type Entry = Record<

```ts
const defaultEntry = {
// default support for other suffixes such as ts, tsx, jsx, mjs, cjs
index: 'src/index.js',
// Rsbuild also supports other suffixes by default, such as ts, tsx, jsx, mts, cts, mjs, cjs
index: './src/index.js',
};
```

Expand Down
4 changes: 2 additions & 2 deletions website/docs/zh/config/source/entry.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ type Entry = Record<

```ts
const defaultEntry = {
// 默认支持其他后缀,如 ts、tsx、jsx、mjs、cjs
index: 'src/index.js',
// Rsbuild 默认也支持其他后缀名,如 ts、tsx、jsx、mts、cts、mjs、cjs
index: './src/index.js',
};
```

Expand Down

1 comment on commit 87e1350

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

📝 Ran ecosystem CI: Open

suite result
modernjs ❌ failure
plugins ✅ success
rspress ✅ success
rslib ✅ success
examples ✅ success

Please sign in to comment.