diff --git a/test/basic/snapshots/test.js.md b/test/basic/snapshots/test.js.md index 8e8f824..6d98cb5 100644 --- a/test/basic/snapshots/test.js.md +++ b/test/basic/snapshots/test.js.md @@ -58,12 +58,6 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 [ - { - code: undefined, - fileName: 'script.html.body.script.js-e3b82208.js.map', - map: undefined, - source: '{"version":3,"file":"script.html.body.script.js-e3b82208.js","sources":["../batman.js","../script.html.body.script.js"],"sourcesContent":["export const b = ()=>\'batman\';\\nconsole.log(b());\\n","\\n import {b} from \\"./batman.js\\";\\n document.body.appendChild(\\n document.createTextNode(`Inline script including ${b()}`)\\n );\\n "],"names":[],"mappings":"AAAO,MAAM,CAAC,GAAG,IAAI,QAAQ,CAAC;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;ACCJ,QAAQ,CAAC,IAAI,CAAC,WAAW;AACrC,gBAAgB,QAAQ,CAAC,cAAc,CAAC,CAAC,wBAAwB,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACzE,aAAa"}', - }, { code: undefined, fileName: 'script.html', @@ -83,4 +77,10 @@ Generated by [AVA](https://avajs.dev). ␊ `, }, + { + code: undefined, + fileName: 'script.html.body.script.js-e3b82208.js.map', + map: undefined, + source: '{"version":3,"file":"script.html.body.script.js-e3b82208.js","sources":["../batman.js","../script.html.body.script.js"],"sourcesContent":["export const b = ()=>\'batman\';\\nconsole.log(b());\\n","\\n import {b} from \\"./batman.js\\";\\n document.body.appendChild(\\n document.createTextNode(`Inline script including ${b()}`)\\n );\\n "],"names":[],"mappings":"AAAO,MAAM,CAAC,GAAG,IAAI,QAAQ,CAAC;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;ACCJ,QAAQ,CAAC,IAAI,CAAC,WAAW;AACrC,gBAAgB,QAAQ,CAAC,cAAc,CAAC,CAAC,wBAAwB,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACzE,aAAa"}', + }, ] diff --git a/test/basic/snapshots/test.js.snap b/test/basic/snapshots/test.js.snap index e34aabd..9432e76 100644 Binary files a/test/basic/snapshots/test.js.snap and b/test/basic/snapshots/test.js.snap differ diff --git a/test/multi-entry/snapshots/test.js.md b/test/multi-entry/snapshots/test.js.md index 7048e2e..e2a246c 100644 --- a/test/multi-entry/snapshots/test.js.md +++ b/test/multi-entry/snapshots/test.js.md @@ -9,6 +9,33 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 [ + { + code: undefined, + fileName: 'admin/index.html', + map: undefined, + source: `␊ + ␊ + ␊ +
␊ + ␊ + ␊ + ␊ + `, + }, + { + code: undefined, + fileName: 'admin/index.html.body.script.js-15dfaff3.js.map', + map: undefined, + source: '{"version":3,"file":"index.html.body.script.js-15dfaff3.js","sources":["../../app/admin-deps.js","../../admin/index.html.body.script.js"],"sourcesContent":["export function adminDeps(){\\n return \\"robin!\\";\\n}\\n","\\n import {bootstrap} from \\"../app/app.js\\"\\n import {adminDeps} from \\"../app/admin-deps.js\\";\\n bootstrap(document.getElementById(\'root\'), adminDeps());\\n "],"names":[],"mappings":";;AAAO,SAAS,SAAS,EAAE;AAC3B,IAAI,OAAO,QAAQ,CAAC;AACpB;;ACCY,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC"}', + }, { code: `const bootstrap = (el,deps = [])=>{␊ el.innerHtml = \`␊ @@ -41,18 +68,6 @@ Generated by [AVA](https://avajs.dev). }, source: undefined, }, - { - code: undefined, - fileName: 'index.html.body.script.js-45303f0f.js.map', - map: undefined, - source: '{"version":3,"file":"index.html.body.script.js-45303f0f.js","sources":["../index.html.body.script.js"],"sourcesContent":["\\n import {bootstrap} from \\"./app/app.js\\"\\n bootstrap(document.getElementById(\'root\'), \\"\\");\\n "],"names":[],"mappings":";;AAEY,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC"}', - }, - { - code: undefined, - fileName: 'admin/index.html.body.script.js-15dfaff3.js.map', - map: undefined, - source: '{"version":3,"file":"index.html.body.script.js-15dfaff3.js","sources":["../../app/admin-deps.js","../../admin/index.html.body.script.js"],"sourcesContent":["export function adminDeps(){\\n return \\"robin!\\";\\n}\\n","\\n import {bootstrap} from \\"../app/app.js\\"\\n import {adminDeps} from \\"../app/admin-deps.js\\";\\n bootstrap(document.getElementById(\'root\'), adminDeps());\\n "],"names":[],"mappings":";;AAAO,SAAS,SAAS,EAAE;AAC3B,IAAI,OAAO,QAAQ,CAAC;AACpB;;ACCY,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC"}', - }, { code: undefined, fileName: 'app-01141b67.js.map', @@ -78,23 +93,8 @@ Generated by [AVA](https://avajs.dev). }, { code: undefined, - fileName: 'admin/index.html', + fileName: 'index.html.body.script.js-45303f0f.js.map', map: undefined, - source: `␊ - ␊ - ␊ -
␊ - ␊ - ␊ - ␊ - `, + source: '{"version":3,"file":"index.html.body.script.js-45303f0f.js","sources":["../index.html.body.script.js"],"sourcesContent":["\\n import {bootstrap} from \\"./app/app.js\\"\\n bootstrap(document.getElementById(\'root\'), \\"\\");\\n "],"names":[],"mappings":";;AAEY,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC"}', }, ] diff --git a/test/multi-entry/snapshots/test.js.snap b/test/multi-entry/snapshots/test.js.snap index b9a63ee..0103569 100644 Binary files a/test/multi-entry/snapshots/test.js.snap and b/test/multi-entry/snapshots/test.js.snap differ diff --git a/test/util/test.js b/test/util/test.js index ef3e693..1819db7 100644 --- a/test/util/test.js +++ b/test/util/test.js @@ -10,7 +10,10 @@ export const getCode = async (bundle, outputOptions, allFiles = false) => { const { output } = await bundle.generate(outputOptions || { format: 'cjs', exports: 'auto' }); if (allFiles) { - return output.map(({ code, fileName, source, map }) => { + return output.sort((a,b)=> { + if(a.fileName === b.fileName && a.source !== b.source){ return a.source b.fileName? 1 : 0); + }).map(({ code, fileName, source, map }) => { return { code, fileName, diff --git a/test/watch/snapshots/test.js.md b/test/watch/snapshots/test.js.md index 1ae170e..a1117bb 100644 --- a/test/watch/snapshots/test.js.md +++ b/test/watch/snapshots/test.js.md @@ -9,6 +9,18 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 [ + { + code: undefined, + fileName: 'index.html', + map: undefined, + source: `␊ + ␊ + ␊ + ␊ + ␊ + ␊ + `, + }, { code: `const a = 2; // If i show up as a changed file, then the watch test has gone wrong!␊ ␊ @@ -38,16 +50,4 @@ Generated by [AVA](https://avajs.dev). map: undefined, source: '{"version":3,"file":"watched-file-8c4729c5.js","sources":["../watched-file.js"],"sourcesContent":["\\n export const a = 2; // If i show up as a changed file, then the watch test has gone wrong!\\n "],"names":[],"mappings":"AACgB,MAAC,CAAC,GAAG,EAAE;;;;"}', }, - { - code: undefined, - fileName: 'index.html', - map: undefined, - source: `␊ - ␊ - ␊ - ␊ - ␊ - ␊ - `, - }, ] diff --git a/test/watch/snapshots/test.js.snap b/test/watch/snapshots/test.js.snap index 949ee1a..8b1614a 100644 Binary files a/test/watch/snapshots/test.js.snap and b/test/watch/snapshots/test.js.snap differ