@@ -8,7 +8,7 @@ import * as fs from 'fs'
88import { fileURLToPath } from 'url'
99import { EDITOR_API_PACKAGE_NAME } from './tools/config'
1010import { execSync } from 'child_process'
11- import importMetaAssets from './plugins/import-meta-assets -plugin.js'
11+ import carryDtsPlugin from './plugins/rollup-carry-dts -plugin.js'
1212
1313const pkg = JSON . parse (
1414 fs . readFileSync ( new URL ( '../package.json' , import . meta. url ) . pathname ) . toString ( )
@@ -112,17 +112,17 @@ export default rollup.defineConfig([
112112 const dirname = path . dirname ( contributionFile )
113113 const language = path . basename ( dirname )
114114 return < rollup . RollupOptions > {
115- input : {
116- index : contributionFile ,
117- worker : path . resolve (
115+ input : [
116+ contributionFile ,
117+ path . resolve (
118118 dirname ,
119119 (
120120 await glob ( '*.worker.js' , {
121121 cwd : path . dirname ( contributionFile )
122122 } )
123123 ) [ 0 ] !
124124 )
125- } ,
125+ ] ,
126126 treeshake : {
127127 preset : 'smallest'
128128 } ,
@@ -144,11 +144,21 @@ export default rollup.defineConfig([
144144 AMD : false ,
145145 preventAssignment : true
146146 } ) ,
147- importMetaAssets ( ) ,
148147 resolver ,
148+ carryDtsPlugin ( ) ,
149149 {
150150 name : 'loader' ,
151- generateBundle ( ) {
151+ generateBundle ( options , bundle ) {
152+ const allChunkIds = Object . keys ( bundle )
153+
154+ const entryChunkIds : string [ ] = allChunkIds . filter ( ( chunkId ) => {
155+ const output = bundle [ chunkId ] !
156+ return output . type === 'chunk' && output . isEntry
157+ } )
158+
159+ const main = entryChunkIds . find ( ( m ) => m . includes ( 'monaco.contribution' ) ) !
160+ const worker = entryChunkIds . find ( ( m ) => m . includes ( 'worker' ) ) !
161+
152162 const dependencies = Object . fromEntries (
153163 Array . from ( this . getModuleIds ( ) )
154164 . map ( ( id ) => this . getModuleInfo ( id ) ! )
@@ -178,10 +188,10 @@ export default rollup.defineConfig([
178188 description : `monaco-editor ${ language } language features bundled to work with ${ pkg . name } ` ,
179189 exports : {
180190 '.' : {
181- default : './index.js'
191+ default : './' + main
182192 } ,
183193 './worker' : {
184- default : './worker.js'
194+ default : './' + worker
185195 }
186196 } ,
187197 main : 'index.js' ,
@@ -231,7 +241,6 @@ export default rollup.defineConfig([
231241 AMD : false ,
232242 preventAssignment : true
233243 } ) ,
234- importMetaAssets ( ) ,
235244 resolver ,
236245 {
237246 name : 'loader' ,
0 commit comments