@@ -34,7 +34,18 @@ async function bundle(root: string, dts = false): Promise<void> {
3434 outExtensions : ( ) => ( { js : '.js' , dts : '.d.ts' } ) ,
3535 dts,
3636 minify : true ,
37- deps : { onlyBundle : [ 'included' , 'shared' , 'distinct' , 'unused' , 'jpeg-js' ] } ,
37+ deps : {
38+ onlyBundle : [
39+ 'included' ,
40+ 'shared' ,
41+ 'distinct' ,
42+ 'unused' ,
43+ 'jpeg-js' ,
44+ 'included-extra' ,
45+ 'included.extra' ,
46+ 'included_extra' ,
47+ ] ,
48+ } ,
3849 plugins : [ bundledLicenseNotices ( root , path . join ( root , 'dist' ) ) ] ,
3950 logLevel : 'silent' ,
4051 } ) ;
@@ -144,6 +155,36 @@ test('identical notices are shared without losing packages or distinct copyright
144155 assert . equal ( await fs . readFile ( path . join ( root , 'dist/THIRD_PARTY_NOTICES.txt' ) , 'utf8' ) , notices ) ;
145156} ) ;
146157
158+ test ( 'notice references use code-unit ordering for package names' , async ( ) => {
159+ const names = [ 'included_extra' , 'included-extra' , 'included.extra' ] ;
160+ const files : Record < string , string > = {
161+ 'input.ts' : names
162+ . map ( ( name , index ) => `export { value as value${ index } } from '${ name } ';` )
163+ . join ( '\n' ) ,
164+ } ;
165+ for ( const name of names ) {
166+ files [ `node_modules/${ name } /package.json` ] = JSON . stringify ( {
167+ name,
168+ version : '1.0.0' ,
169+ license : 'MIT' ,
170+ main : 'index.js' ,
171+ } ) ;
172+ files [ `node_modules/${ name } /index.js` ] = `export const value = '${ name } ';` ;
173+ files [ `node_modules/${ name } /LICENSE` ] = 'Copyright ordering fixture\nShared license terms.' ;
174+ }
175+ const root = await fixture ( files ) ;
176+ await bundle ( root ) ;
177+ const notices = await fs . readFile ( path . join ( root , 'dist/THIRD_PARTY_NOTICES.txt' ) , 'utf8' ) ;
178+ assert . equal (
179+ notices . split ( '\n\n' ) [ 0 ] ,
180+ [
181+ 182+ 183+ 184+ ] . join ( '\n' ) ,
185+ ) ;
186+ } ) ;
187+
147188test ( 'declaration generation preserves JavaScript dependency notices' , async ( ) => {
148189 const root = await fixture ( {
149190 'input.ts' : "export { value } from 'included';" ,
@@ -166,24 +207,32 @@ test('declaration generation preserves JavaScript dependency notices', async ()
166207 assert . equal ( await fs . readFile ( path . join ( root , 'dist/THIRD_PARTY_NOTICES.txt' ) , 'utf8' ) , notices ) ;
167208} ) ;
168209
169- test ( 'bundled jpeg-js retains source-file notices and the Apache license' , async ( ) => {
170- const root = await fixture ( {
171- 'input.ts' : "export { value } from 'jpeg-js';" ,
172- 'node_modules/jpeg-js/package.json' : JSON . stringify ( {
173- name : 'jpeg-js' ,
174- version : '0.4.4' ,
175- license : 'BSD-3-Clause' ,
176- main : 'index.js' ,
177- } ) ,
178- 'node_modules/jpeg-js/index.js' : 'export const value = process.env.FIXTURE_NUMBER;' ,
179- 'node_modules/jpeg-js/LICENSE' : 'Package-level BSD terms.' ,
180- 'LICENSES/jpeg-js.txt' : 'Copyright 2011 notmasteryet\nCopyright 2008 Adobe.' ,
181- 'LICENSES/Apache-2.0.txt' : 'Full Apache license text.' ,
182- } ) ;
183- await bundle ( root ) ;
184- const notices = await fs . readFile ( path . join ( root , 'dist/THIRD_PARTY_NOTICES.txt' ) , 'utf8' ) ;
185- assert . match ( notices , / P a c k a g e - l e v e l B S D t e r m s / ) ;
186- assert . match ( notices , / C o p y r i g h t 2 0 1 1 n o t m a s t e r y e t / ) ;
187- assert . match ( notices , / C o p y r i g h t 2 0 0 8 A d o b e / ) ;
188- assert . match ( notices , / F u l l A p a c h e l i c e n s e t e x t / ) ;
189- } ) ;
210+ test . each ( [ '0.4.4' , '0.4.5' ] ) (
211+ 'bundled jpeg-js@%s requires matching source-file notices' ,
212+ async ( version ) => {
213+ const root = await fixture ( {
214+ 'input.ts' : "export { value } from 'jpeg-js';" ,
215+ 'node_modules/jpeg-js/package.json' : JSON . stringify ( {
216+ name : 'jpeg-js' ,
217+ version,
218+ license : 'BSD-3-Clause' ,
219+ main : 'index.js' ,
220+ } ) ,
221+ 'node_modules/jpeg-js/index.js' : 'export const value = process.env.FIXTURE_NUMBER;' ,
222+ 'node_modules/jpeg-js/LICENSE' : 'Package-level BSD terms.' ,
223+ 'LICENSES/jpeg-js.txt' :
224+ 'jpeg-js 0.4.4 source-file notices\n\nCopyright 2011 notmasteryet\nCopyright 2008 Adobe.' ,
225+ 'LICENSES/Apache-2.0.txt' : 'Full Apache license text.' ,
226+ } ) ;
227+ if ( version === '0.4.5' ) {
228+ await assert . rejects ( bundle ( root ) , / L I C E N S E S \/ j p e g - j s \. t x t .* j p e g - j s @ 0 \. 4 \. 5 / ) ;
229+ return ;
230+ }
231+ await bundle ( root ) ;
232+ const notices = await fs . readFile ( path . join ( root , 'dist/THIRD_PARTY_NOTICES.txt' ) , 'utf8' ) ;
233+ assert . match ( notices , / P a c k a g e - l e v e l B S D t e r m s / ) ;
234+ assert . match ( notices , / C o p y r i g h t 2 0 1 1 n o t m a s t e r y e t / ) ;
235+ assert . match ( notices , / C o p y r i g h t 2 0 0 8 A d o b e / ) ;
236+ assert . match ( notices , / F u l l A p a c h e l i c e n s e t e x t / ) ;
237+ } ,
238+ ) ;
0 commit comments