11import { basename , extname , join , relative } from "path" ;
2- import {
3- has ,
4- isEmpty ,
5- keys ,
6- map ,
7- mapKeys ,
8- mapValues
9- } from "@innoai-tech/lodash" ;
10- import commonjs from "@rollup/plugin-commonjs" ;
11- import { nodeResolve } from "@rollup/plugin-node-resolve" ;
2+ import { forEach , has , isEmpty , keys , mapKeys , mapValues , set , startsWith } from "@innoai-tech/lodash" ;
123import { readFile , unlink } from "fs/promises" ;
134import { globby } from "globby" ;
14- import { type OutputOptions , rollup } from "rollup " ;
5+ import { type OutputOptions , rolldown } from "rolldown " ;
156import { createAutoExternal } from "./autoExternal" ;
167import { bootstrap } from "./bootstrap" ;
17- import { esbuild } from "./esbuild" ;
18- import { getBuildTargets } from "./getTarget" ;
198import { createLogger } from "./log" ;
209import { patchShebang } from "./patchShebang" ;
2110import { resolveProjectRoot } from "./pm" ;
22- import {
23- type MonoBundleOptions ,
24- entryAlias ,
25- writeFormattedJsonFile
26- } from "./util" ;
27- import { forEach , set , startsWith } from "@innoai-tech/lodash" ;
11+ import { entryAlias , type MonoBundleOptions , writeFormattedJsonFile } from "./util" ;
2812import { chunkCleanup } from "./chunkCleanup.ts" ;
2913import { vueComponentComplete } from "./vueComponentComplete.ts" ;
3014
@@ -85,11 +69,7 @@ export const bundle = async ({
8569 sideDeps : options [ "sideDeps" ] as any
8670 } ) ;
8771
88- const buildTargets = getBuildTargets (
89- ( pkg as any ) . browserslist ?? [ "defaults" ]
90- ) ;
91-
92- const rollupOptions = [
72+ const rolldownOptions = [
9373 {
9474 input : inputs ,
9575 output : {
@@ -98,17 +78,13 @@ export const bundle = async ({
9878 entryFileNames : "[name].mjs" ,
9979 chunkFileNames : "[name]-[hash].mjs"
10080 } ,
81+ resolve : {
82+ extensions : [ ".ts" , ".tsx" , ".mjs" , "" , ".js" , ".jsx" ]
83+ } ,
84+ tsconfig : tsconfigFile ,
10185 plugins : [
10286 autoExternal ( ) ,
103- nodeResolve ( {
104- extensions : [ ".ts" , ".tsx" , ".mjs" , "" , ".js" , ".jsx" ]
105- } ) ,
106- commonjs ( ) ,
10787 vueComponentComplete ( { } ) ,
108- esbuild ( {
109- tsconfig : tsconfigFile ,
110- target : map ( buildTargets , ( v , k ) => `${ k } ${ v } ` )
111- } ) ,
11288 patchShebang ( ( chunkName ) => {
11389 return ! ! options . exports ?. [
11490 `bin:${ basename ( chunkName , extname ( chunkName ) ) } `
@@ -125,15 +101,15 @@ export const bundle = async ({
125101 await unlink ( join ( cwd , f ) ) ;
126102 }
127103
128- logger . warning ( `bundling (target: ${ JSON . stringify ( buildTargets ) } ) ` ) ;
104+ logger . warning ( `bundling` ) ;
129105
130106 const outputFiles : { [ k : string ] : boolean } = { } ;
131107
132- for ( const rollupOption of rollupOptions ) {
133- const files = await rollup ( rollupOption ) . then ( ( bundle ) => {
108+ for ( const rolldownOption of rolldownOptions ) {
109+ const files = await rolldown ( rolldownOption ) . then ( ( bundle ) => {
134110 return Promise . all (
135111 ( [ ] as OutputOptions [ ] )
136- . concat ( rollupOption . output ?? [ ] )
112+ . concat ( rolldownOption . output ?? [ ] )
137113 . map ( ( output ) => {
138114 if ( dryRun ) {
139115 return [ ] ;
0 commit comments