Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dev jsxruntimepath #383

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
6 changes: 4 additions & 2 deletions packages/pkg/src/helpers/getSwcConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { TaskName } from '../types.js';
import type { UserConfig } from '../types.js';
import type { Config, ModuleConfig } from '@swc/core';

const __DEV__ = `${process.env.NODE_ENV === 'development'}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

这里不应该直接判断好是 dev 还是 production 吗

Copy link
Author

Choose a reason for hiding this comment

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

源码image
未修改的
image
修复后的image


export const getBundleSwcConfig = (userConfig: UserConfig, taskName: TaskName): Config => {
const define = stringifyObject(userConfig?.define ?? {});

Expand All @@ -29,7 +31,7 @@ export const getBundleSwcConfig = (userConfig: UserConfig, taskName: TaskName):
globals: {
vars: {
// Insert __DEV__ for users, can be overrided too.
__DEV__: "process.env.NODE_ENV === 'development'",
__DEV__,
...define,
},
},
Expand Down Expand Up @@ -67,7 +69,7 @@ export const getTransformSwcConfig = (userConfig: UserConfig, taskName: TaskName
globals: {
vars: {
// Insert __DEV__ for users, can be overrided too.
__DEV__: "process.env.NODE_ENV === 'development'",
__DEV__,
...define,
},
},
Expand Down
4 changes: 3 additions & 1 deletion packages/plugin-docusaurus/src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ module.exports = function (context) {

const styleUnitPath = require.resolve('style-unit', requireOptions);

const jsxRuntimePath = require.resolve('react/jsx-runtime', requireOptions);

return {
name: 'docusaurus-plugin',
configureWebpack(config) {
Expand All @@ -28,7 +30,7 @@ module.exports = function (context) {
return {
resolve: {
alias: {
'react/jsx-runtime': path.resolve(siteDir, 'node_modules/react/jsx-runtime'),
'react/jsx-runtime': jsxRuntimePath,
'@mdx-js/react': mdxReactPath,
'style-unit': styleUnitPath,
// FIXME: I am not sure how to resolve the actual output folder
Expand Down