@@ -4,8 +4,6 @@ import { dirname, relative, join as joinPath, resolve as resolvePath } from 'pat
44import { fileURLToPath } from 'url'
55
66import type { Alias , InlineConfig } from 'vite'
7- // import globPlugin from 'vite-plugin-glob'
8- import { nodeResolve } from '@rollup/plugin-node-resolve'
97
108import type { SuiteSummary } from '@sdeverywhere/check-core'
119
@@ -48,24 +46,10 @@ export function createViteConfigForReport(
4846 // referenced by the check bundle (specifically in the Node implementation of
4947 // threads.js). These are not actually used in the browser, so we just need
5048 // to provide no-op polyfills for these.
51- const polyfillAlias = ( find : string ) => {
49+ const noopPolyfillAlias = ( find : string ) => {
5250 return {
5351 find,
54- replacement : find ,
55- customResolver : async function ( _source , _importer , options ) {
56- const customResolver = nodeResolve ( )
57- // Replace uses of Node built-ins (e.g. 'events') with the appropriate polyfill
58- const customSource = `rollup-plugin-node-polyfills/polyfills/${ find } `
59- // Use this file as the "importer" so that we resolve `rollup-plugin-node-polyfills`
60- // relative to `plugin-check/node_modules`. Without this workaround, the consuming
61- // project would need `rollup-plugin-node-polyfills` as an explicit dependency, and
62- // we want to avoid that since it's more of an implementation detail.
63- const customImporter = __filename
64- // Note that we need to use `resolveId.call` here in order to provide the
65- // right `this` context, which provides Rollup plugin functionality
66- const resolved = await customResolver . resolveId . call ( this , customSource , customImporter , options )
67- return resolved . id
68- }
52+ replacement : '/polyfills/noop-polyfills.ts'
6953 } as Alias
7054 }
7155
@@ -116,15 +100,13 @@ export function createViteConfigForReport(
116100 // Make the overlay use the `messages.html` file that is written to the prep directory
117101 alias ( '@_prep_' , prepDir ) ,
118102
119- // XXX: Include polyfills for these modules that are used in the Node-specific
120- // implementation of threads.js; this allows us to use one bundle that works
121- // in both Node and browser environments
122- polyfillAlias ( 'events' ) ,
123- polyfillAlias ( 'os' ) ,
124- polyfillAlias ( 'path' ) ,
125- // XXX: The following is only needed due to threads.js 1.7.0 importing `fileURLToPath`.
126- // We use a no-op polyfill of our own for the time being.
127- alias ( 'url' , '/src/url-polyfill.ts' )
103+ // XXX: Include no-op polyfills for these modules that are used in the Node-specific
104+ // implementation of threads.js; this allows us to use one bundle that works in both
105+ // Node and browser environments
106+ noopPolyfillAlias ( 'events' ) ,
107+ noopPolyfillAlias ( 'os' ) ,
108+ noopPolyfillAlias ( 'path' ) ,
109+ noopPolyfillAlias ( 'url' )
128110 ]
129111 } ,
130112
0 commit comments