@@ -309,4 +309,79 @@ export { spectral as default };
309309` ) ;
310310 } ) ;
311311 } ) ;
312+
313+ it ( 'given fullOutput set to true, should expose the entire built chunk' , async ( ) => {
314+ serveAssets ( {
315+ '/p/.spectral/my-fn.mjs' : `import {isOdd} from './helpers/index.mjs';
316+
317+ export default (input) => {
318+ if (!isOdd(input)) {
319+ return [{ message: 'must be odd' }];
320+ }
321+ };` ,
322+
323+ 'https://cdn.skypack.dev/lodash.uppercase' :
`export * from '/-/[email protected] /dist=es2020,mode=imports/optimized/lodash.uppercase.js'; 324+ export {default} from '/-/[email protected] /dist=es2020,mode=imports/optimized/lodash.uppercase.js';` , 325+
326+ 'https://cdn.skypack.dev/-/[email protected] /dist=es2020,mode=imports/optimized/lodash.uppercase.js' :
327+ 'export default (a) => a.toUpperCase()' ,
328+
329+ '/p/.spectral/upper-case.mjs' : `import upperCase from 'https://cdn.skypack.dev/lodash.uppercase';
330+
331+ export default (input) => {
332+ if (upperCase(input) !== input) {
333+ return [{ message: 'must be upper case' }];
334+ }
335+ };` ,
336+
337+ '/p/.spectral/lower-case.mjs' : `import lowerCase from 'lodash.lowercase';
338+
339+ export default (input) => {
340+ if (lowerCase(input) !== input) {
341+ return [{ message: 'must be lower case' }];
342+ }
343+ };` ,
344+
345+ '/p/.spectral/helpers/index.mjs' : `export * from './is-odd.mjs';` ,
346+ '/p/.spectral/helpers/is-odd.mjs' : `export const isOdd = (value) => value % 2 === 1` ,
347+
348+ '/p/spectral.mjs' : `import myFn from './.spectral/my-fn.mjs';
349+ import lowerCase from './.spectral/lower-case.mjs';
350+ import upperCase from './.spectral/upper-case.mjs';
351+
352+ export default {
353+ rules: {
354+ 'odd-rule': {
355+ given: '$',
356+ then: { function: myFn },
357+ },
358+ 'upper-case-rule': {
359+ given: '$',
360+ then: { function: upperCase },
361+ },
362+ 'lower-case-rule': {
363+ given: '$',
364+ then: { function: lowerCase },
365+ },
366+ },
367+ };` ,
368+ } ) ;
369+
370+ const bundle = await bundleRuleset ( '/p/spectral.mjs' , {
371+ target : 'node' ,
372+ plugins : [ ...node ( io ) , virtualFs ( io ) ] ,
373+ fullOutput : true ,
374+ } ) ;
375+
376+ expect ( Object . keys ( bundle . modules ) . sort ( ) ) . toStrictEqual ( [
377+ '/p/.spectral/helpers/index.mjs' ,
378+ '/p/.spectral/helpers/is-odd.mjs' ,
379+ '/p/.spectral/lower-case.mjs' ,
380+ '/p/.spectral/my-fn.mjs' ,
381+ '/p/.spectral/upper-case.mjs' ,
382+ '/p/spectral.mjs' ,
383+ 'https://cdn.skypack.dev/-/[email protected] /dist=es2020,mode=imports/optimized/lodash.uppercase.js' , 384+ 'https://cdn.skypack.dev/lodash.uppercase' ,
385+ ] ) ;
386+ } ) ;
312387} ) ;
0 commit comments