forked from zhangyuang/ssr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support optimizeDeps in vite, add react-is as deps when use antd5
- Loading branch information
1 parent
3f660a6
commit 66fa36e
Showing
6 changed files
with
36 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { coerce } from 'semver' | ||
import { getPkgJson } from './cwd' | ||
|
||
export const judgeAntd = () => { | ||
const antdVersion = getPkgJson().dependencies?.['antd'] ?? getPkgJson().devDependencies?.['antd'] | ||
return coerce(antdVersion)?.major | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
import { promises } from 'fs' | ||
import { coerce } from 'semver' | ||
import { resolve } from 'path' | ||
import type { Chain, PluginItem } from 'ssr-types' | ||
import type { Rule, Module } from 'webpack-chain' | ||
import type { Compiler } from 'webpack' | ||
import { getImageOutputPath } from '../parse' | ||
import { loadModuleFromFramework, getPkgJson, judgeFramework, getCwd } from '../cwd' | ||
import { loadModuleFromFramework, judgeFramework, getCwd } from '../cwd' | ||
import { loadConfig } from '../loadConfig' | ||
import { logWarning } from '../log' | ||
import { judgeAntd } from '../judge' | ||
import { asyncChunkMap } from '../build-utils' | ||
|
||
const antdVersion = getPkgJson().dependencies?.['antd'] ?? getPkgJson().devDependencies?.['antd'] | ||
const isAntd4 = coerce(antdVersion)?.major === 4 | ||
if (coerce(antdVersion)?.major === 5) { | ||
const antdVersion = judgeAntd() | ||
const isAntd4 = antdVersion === 4 | ||
if (antdVersion === 5) { | ||
logWarning('Check [email protected] has been installed, [email protected] is more recommend in ssr environment') | ||
} | ||
const addBabelLoader = (chain: Rule<Module>, envOptions: any, isServer: boolean) => { | ||
|
@@ -127,7 +127,7 @@ const addCommonChain = (chain: Chain, isServer: boolean) => { | |
.test(/\.(js|mjs|jsx|ts|tsx)$/) | ||
.exclude | ||
.add(/node_modules|core-js/) | ||
.add(babelOptions?.exclude as Array<string|RegExp> ?? []) | ||
.add(babelOptions?.exclude as Array<string | RegExp> ?? []) | ||
.end() | ||
|
||
chain.module | ||
|
@@ -141,7 +141,7 @@ const addCommonChain = (chain: Chain, isServer: boolean) => { | |
.test(/\.(js|mjs|jsx|ts|tsx)$/) | ||
.include | ||
|
||
const babelForExtraModule = module.add(babelExtraModule ?? []).add(babelOptions?.include as Array<string|RegExp> ?? []).end().exclude.add(/core-js/).end() | ||
const babelForExtraModule = module.add(babelExtraModule ?? []).add(babelOptions?.include as Array<string | RegExp> ?? []).end().exclude.add(/core-js/).end() | ||
|
||
addBabelLoader(babelModule, envOptions, isServer) | ||
addBabelLoader(babelForExtraModule, envOptions, isServer) | ||
|