MCPcopy Create free account
hub / github.com/BridgeAR/safe-stable-stringify / testBundlers

Function testBundlers

test-modules.js:96–135  ·  view source on GitHub ↗

@param {import('tap').Test} assert

(assert)

Source from the content-addressed store, hash-verified

94
95/** @param {import('tap').Test} assert */
96async function testBundlers (assert) {
97 const directory = createPackageFixture(assert)
98 await Promise.all([
99 build({
100 entryPoints: [join(directory, 'consumer.mjs')],
101 bundle: true,
102 platform: 'browser',
103 format: 'esm',
104 minify: true,
105 outfile: join(directory, 'esbuild.mjs')
106 }),
107 build({
108 entryPoints: [join(directory, 'consumer.cjs')],
109 bundle: true,
110 platform: 'browser',
111 format: 'cjs',
112 minify: true,
113 outfile: join(directory, 'esbuild.cjs')
114 })
115 ])
116 const rollupEntry = join(directory, 'node_modules', 'safe-stable-stringify', 'esm', 'wrapper.mjs')
117 const bundle = await rollup({ input: rollupEntry })
118 try {
119 await bundle.write({ file: join(directory, 'rollup.mjs'), format: 'esm' })
120 } finally {
121 await bundle.close()
122 }
123 const esmSource = readFileSync(join(directory, 'consumer.mjs'), 'utf8')
124 runInNewContext(readFileSync(join(directory, 'esbuild.cjs'), 'utf8'))
125 writeFileSync(join(directory, 'rollup-consumer.mjs'), esmSource.replace('safe-stable-stringify', './rollup.mjs'))
126 const results = await Promise.all([
127 runNode([join(directory, 'esbuild.mjs')]),
128 runNode([join(directory, 'esbuild.cjs')]),
129 runNode([join(directory, 'rollup-consumer.mjs')])
130 ])
131 for (const { stdout, stderr } of results) {
132 assert.equal(stdout, '', 'bundle produces no output')
133 assert.equal(stderr, '', 'bundle produces no errors')
134 }
135}
136
137test('bundlers preserve the side effect and exports', testBundlers)
138

Callers

nothing calls this directly

Calls 2

createPackageFixtureFunction · 0.85
runNodeFunction · 0.85

Tested by

no test coverage detected