@@ -1255,12 +1255,10 @@ test(`should generate export {} when there are no exports in source file`, async
1255
1255
} )
1256
1256
1257
1257
test ( 'custom inject style function' , async ( ) => {
1258
- const { outFiles, getFileContent } = await run (
1259
- getTestName ( ) ,
1260
- {
1261
- 'input.ts' : `import './style.css'` ,
1262
- 'style.css' : `.hello { color: red }` ,
1263
- 'tsup.config.ts' : `
1258
+ const { outFiles, getFileContent } = await run ( getTestName ( ) , {
1259
+ 'input.ts' : `import './style.css'` ,
1260
+ 'style.css' : `.hello { color: red }` ,
1261
+ 'tsup.config.ts' : `
1264
1262
export default {
1265
1263
entry: ['src/input.ts'],
1266
1264
minify: true,
@@ -1269,13 +1267,30 @@ test('custom inject style function', async () => {
1269
1267
return "__custom_inject_style__(" + css +")";
1270
1268
}
1271
1269
}` ,
1272
- } ,
1273
- )
1270
+ } )
1274
1271
expect ( outFiles ) . toEqual ( [ 'input.js' , 'input.mjs' ] )
1275
- expect ( await getFileContent ( 'dist/input.mjs' ) ) . toContain ( '__custom_inject_style__(`.hello{color:red}\n`)' )
1276
- expect ( await getFileContent ( 'dist/input.js' ) ) . toContain ( '__custom_inject_style__(`.hello{color:red}\n`)' )
1272
+ expect ( await getFileContent ( 'dist/input.mjs' ) ) . toContain (
1273
+ '__custom_inject_style__(`.hello{color:red}\n`)'
1274
+ )
1275
+ expect ( await getFileContent ( 'dist/input.js' ) ) . toContain (
1276
+ '__custom_inject_style__(`.hello{color:red}\n`)'
1277
+ )
1277
1278
} )
1278
1279
1280
+ test ( 'preserve top-level variable for IIFE format' , async ( ) => {
1281
+ const { outFiles, getFileContent } = await run ( getTestName ( ) , {
1282
+ 'input.ts' : `export default 'foo'` ,
1283
+ 'tsup.config.ts' : `
1284
+ export default {
1285
+ entry: ['src/input.ts'],
1286
+ globalName: 'globalFoo',
1287
+ minify: 'terser',
1288
+ format: ['iife']
1289
+ }` ,
1290
+ } )
1291
+ expect ( outFiles ) . toEqual ( [ 'input.global.js' ] )
1292
+ expect ( await getFileContent ( 'dist/input.global.js' ) ) . toMatch ( / g l o b a l F o o \s * = / )
1293
+ } )
1279
1294
1280
1295
test ( 'should load postcss esm config' , async ( ) => {
1281
1296
const { outFiles, getFileContent } = await run ( getTestName ( ) , {
@@ -1301,4 +1316,4 @@ test('should load postcss esm config', async () => {
1301
1316
1302
1317
expect ( outFiles ) . toEqual ( [ 'input.cjs' , 'input.css' ] )
1303
1318
expect ( await getFileContent ( 'dist/input.css' ) ) . toContain ( 'color: blue;' )
1304
- } )
1319
+ } )
0 commit comments