@@ -715,45 +715,34 @@ async function prepareRolldownOptimizerRun(
715
715
716
716
const optimizeDeps = getDepOptimizationConfig ( config , ssr )
717
717
718
- const { plugins : pluginsFromConfig = [ ] , ...rollupOptions } =
719
- optimizeDeps ?. rollupOptions ?? { }
720
718
const { plugins : pluginsFromConfig = [ ] , ...rollupOptions } =
721
719
optimizeDeps ?. rollupOptions ?? { }
722
720
723
- let jsxLoader = false
724
721
let jsxLoader = false
725
722
await Promise . all (
726
723
Object . keys ( depsInfo ) . map ( async ( id ) => {
727
724
const src = depsInfo [ id ] . src !
728
725
const exportsData = await ( depsInfo [ id ] . exportsData ??
729
726
extractExportsData ( src , config , ssr ) )
730
- if ( exportsData . jsxLoader ) {
731
727
if ( exportsData . jsxLoader ) {
732
728
// Ensure that optimization won't fail by defaulting '.js' to the JSX parser.
733
729
// This is useful for packages such as Gatsby.
734
730
jsxLoader = true
735
- jsxLoader = true
736
731
}
737
732
const flatId = flattenId ( id )
738
733
flatIdDeps [ flatId ] = src
739
734
idToExports [ id ] = exportsData
740
735
} ) ,
741
736
)
742
737
743
- if ( optimizerContext . cancelled ) return { build : undefined , idToExports }
744
738
if ( optimizerContext . cancelled ) return { build : undefined , idToExports }
745
739
746
- // In lib mode, we need to keep process.env.NODE_ENV untouched
747
740
// In lib mode, we need to keep process.env.NODE_ENV untouched
748
741
const define = {
749
742
'process.env.NODE_ENV' :
750
743
isBuild && config . build . lib
751
744
? 'process.env.NODE_ENV'
752
745
: JSON . stringify ( process . env . NODE_ENV || config . mode ) ,
753
- 'process.env.NODE_ENV' :
754
- isBuild && config . build . lib
755
- ? 'process.env.NODE_ENV'
756
- : JSON . stringify ( process . env . NODE_ENV || config . mode ) ,
757
746
}
758
747
759
748
const platform =
@@ -781,35 +770,11 @@ async function prepareRolldownOptimizerRun(
781
770
}
782
771
}
783
772
784
- const plugins = await asyncFlatten (
785
- Array . isArray ( pluginsFromConfig ) ? pluginsFromConfig : [ pluginsFromConfig ] ,
786
- )
787
- if ( isBuild ) {
788
- let rollupOptionsExternal = config ?. build ?. rollupOptions ?. external
789
- if ( rollupOptionsExternal ) {
790
- if ( typeof rollupOptionsExternal === 'string' ) {
791
- rollupOptionsExternal = [ rollupOptionsExternal ]
792
- }
793
- // TODO: decide whether to support RegExp and function options
794
- // They're not supported yet because `optimizeDeps.exclude` currently only accepts strings
795
- if (
796
- ! Array . isArray ( rollupOptionsExternal ) ||
797
- rollupOptionsExternal . some ( ( ext ) => typeof ext !== 'string' )
798
- ) {
799
- throw new Error (
800
- `[vite] 'build.rollupOptions.external' can only be an array of strings or a string when using esbuild optimization at build time.` ,
801
- )
802
- }
803
- external . push ( ...( rollupOptionsExternal as string [ ] ) )
804
- }
805
- }
806
-
807
773
const plugins = await asyncFlatten (
808
774
Array . isArray ( pluginsFromConfig ) ? pluginsFromConfig : [ pluginsFromConfig ] ,
809
775
)
810
776
if ( external . length ) {
811
777
plugins . push ( rolldownCjsExternalPlugin ( external , platform ) )
812
- plugins . push ( rolldownCjsExternalPlugin ( external , platform ) )
813
778
}
814
779
plugins . push ( rolldownDepPlugin ( flatIdDeps , external , config , ssr ) )
815
780
plugins . push ( {
@@ -839,7 +804,7 @@ async function prepareRolldownOptimizerRun(
839
804
async function build ( ) {
840
805
const bundle = await rolldown . rolldown ( {
841
806
input : Object . keys ( flatIdDeps ) ,
842
- external,
807
+ // external,
843
808
logLevel : 'warn' ,
844
809
plugins,
845
810
resolve : {
@@ -1385,4 +1350,4 @@ const safeRename = promisify(function gracefulRename(
1385
1350
}
1386
1351
if ( cb ) cb ( er )
1387
1352
} )
1388
- } )
1353
+ } )
0 commit comments