Skip to content

Commit

Permalink
fix(dev): do not process mdx files in devCommonJsPlugin (#1125)
Browse files Browse the repository at this point in the history
close #1119
  • Loading branch information
dai-shi authored Jan 5, 2025
1 parent a15317b commit 52f7ad6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/waku/src/lib/plugins/vite-plugin-dev-commonjs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { transformWithEsbuild } from 'vite';
import type { Plugin } from 'vite';

import { EXTENSIONS } from '../constants.js';
import { extname } from '../utils/path.js';

// https://github.com/vite-plugin/vite-plugin-commonjs/blob/5e3294e78fabb037e12aab75433908fbee17192a/src/utils.ts#L9-L15
const isCommonjs = (code: string) =>
/\b(?:require|module|exports)\b/.test(
Expand All @@ -18,6 +21,10 @@ export function devCommonJsPlugin(opts: {
return;
}
} else {
const ext = extname(id.split('?')[0]!);
if (!EXTENSIONS.includes(ext)) {
return;
}
if (code.startsWith("import { createRequire } from 'module';")) {
return;
}
Expand Down

0 comments on commit 52f7ad6

Please sign in to comment.