@@ -190,7 +190,6 @@ async function runDtsBundler(entrypoint, output) {
190190 * @typedef BundlerTaskOptions
191191 * @property {string[] } [external]
192192 * @property {boolean } [exportIsTsObject]
193- * @property {boolean } [setDynamicImport]
194193 * @property {boolean } [treeShaking]
195194 */
196195function createBundler ( entrypoint , outfile , taskOptions = { } ) {
@@ -257,22 +256,12 @@ function createBundler(entrypoint, outfile, taskOptions = {}) {
257256 } ;
258257
259258 if ( taskOptions . exportIsTsObject ) {
260- // These snippets cannot appear in the actual source files, otherwise they will be rewritten
261- // to things like exports or requires.
262-
259+ // We use an IIFE so we can inject the footer, and so that "ts" is global if not loaded as a module.
260+ options . format = "iife" ;
261+ // Name the variable ts, matching our old big bundle and so we can use the code below.
262+ options . globalName = "ts" ;
263263 // If we are in a CJS context, export the ts namespace.
264- let footer = `\nif (typeof module !== "undefined" && module.exports) { module.exports = ts; }` ;
265-
266- if ( taskOptions . setDynamicImport ) {
267- // If we are in a server bundle, inject the dynamicImport function.
268- // This only works because the web server's "start" function returns;
269- // the node server does not, but we don't use this there.
270- footer += `\nif (ts.server && ts.server.setDynamicImport) { ts.server.setDynamicImport(id => import(id)); }` ;
271- }
272-
273- options . format = "iife" ; // We use an IIFE so we can inject the footer, and so that "ts" is global if not loaded as a module.
274- options . globalName = "ts" ; // Name the variable ts, matching our old big bundle and so we can use the code below.
275- options . footer = { js : footer } ;
264+ options . footer = { js : `\nif (typeof module !== "undefined" && module.exports) { module.exports = ts; }` } ;
276265 }
277266
278267 return options ;
@@ -416,7 +405,7 @@ const { main: tsserver, watch: watchTsserver } = entrypointBuildTask({
416405 // this is used in the browser too. Do the same thing that we do for our
417406 // libraries and generate an IIFE with name `ts`, as to not pollute the global
418407 // scope.
419- bundlerOptions : { exportIsTsObject : true , setDynamicImport : true } ,
408+ bundlerOptions : { exportIsTsObject : true } ,
420409} ) ;
421410export { tsserver , watchTsserver } ;
422411
0 commit comments