File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
packages/plugin/vite/src/config Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -7,11 +7,18 @@ import {
77 pluginHotRestart ,
88} from './vite.base.config' ;
99
10+ import fs from 'fs-extra' ;
11+ import path from 'node:path' ;
12+
1013export function getConfig (
1114 forgeEnv : ConfigEnv < 'build' > ,
1215 userConfig : UserConfig = { } ,
1316) : UserConfig {
14- const { forgeConfigSelf } = forgeEnv ;
17+ const { forgeConfigSelf, root } = forgeEnv ;
18+ const packageJson = JSON . parse (
19+ fs . readFileSync ( path . join ( root , 'package.json' ) ) ,
20+ ) ;
21+
1522 const define = getBuildDefine ( forgeEnv ) ;
1623 const config : UserConfig = {
1724 build : {
@@ -34,7 +41,7 @@ export function getConfig(
3441 config . build ! . lib = {
3542 entry : forgeConfigSelf . entry ,
3643 fileName : ( ) => '[name].js' ,
37- formats : [ 'cjs' ] ,
44+ formats : packageJson . type !== 'module' ? [ 'cjs' ] : [ 'esm '] ,
3845 } ;
3946 }
4047
You can’t perform that action at this time.
0 commit comments