Skip to content

Commit

Permalink
fix(browser): don't inject empty process global (#6213)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va authored Jul 24, 2024
1 parent 1f9d82e commit 1affb99
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
27 changes: 14 additions & 13 deletions packages/browser/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,18 @@ export default () =>
}),
],
},
{
input: './src/client/tester/jest-dom.ts',
output: {
file: './jest-dom.d.ts',
format: 'esm',
},
external: [],
plugins: [
dts({
respectExternal: true,
}),
],
},
// Should be built only when we update the jest-dom package
// {
// input: './src/client/tester/jest-dom.ts',
// output: {
// file: './jest-dom.d.ts',
// format: 'esm',
// },
// external: [],
// plugins: [
// dts({
// respectExternal: true,
// }),
// ],
// },
])
26 changes: 12 additions & 14 deletions packages/browser/src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ export default (browserServer: BrowserServer, base = '/'): Plugin[] => {
const define: Record<string, string> = {}
for (const env in (project.config.env || {})) {
const stringValue = JSON.stringify(project.config.env[env])
define[`process.env.${env}`] = stringValue
define[`import.meta.env.${env}`] = stringValue
}

Expand Down Expand Up @@ -334,21 +333,20 @@ export default (browserServer: BrowserServer, base = '/'): Plugin[] => {
name: 'vitest:browser:support-testing-library',
config() {
return {
define: {
// testing-library/preact
'process.env.PTL_SKIP_AUTO_CLEANUP': !!process.env.PTL_SKIP_AUTO_CLEANUP,
// testing-library/react
'process.env.RTL_SKIP_AUTO_CLEANUP': !!process.env.RTL_SKIP_AUTO_CLEANUP,
'process.env?.RTL_SKIP_AUTO_CLEANUP': !!process.env.RTL_SKIP_AUTO_CLEANUP,
// testing-library/svelte, testing-library/solid
'process.env.STL_SKIP_AUTO_CLEANUP': !!process.env.STL_SKIP_AUTO_CLEANUP,
// testing-library/vue
'process.env.VTL_SKIP_AUTO_CLEANUP': !!process.env.VTL_SKIP_AUTO_CLEANUP,
// dom.debug()
'process.env.DEBUG_PRINT_LIMIT': process.env.DEBUG_PRINT_LIMIT || 7000,
},
optimizeDeps: {
esbuildOptions: {
define: {
// testing-library/preact
'process.env.PTL_SKIP_AUTO_CLEANUP': JSON.stringify(!!process.env.PTL_SKIP_AUTO_CLEANUP),
// testing-library/react
'process.env.RTL_SKIP_AUTO_CLEANUP': JSON.stringify(!!process.env.RTL_SKIP_AUTO_CLEANUP),
// testing-library/svelte, testing-library/solid
'process.env.STL_SKIP_AUTO_CLEANUP': JSON.stringify(!!process.env.STL_SKIP_AUTO_CLEANUP),
// testing-library/vue
'process.env.VTL_SKIP_AUTO_CLEANUP': JSON.stringify(!!process.env.VTL_SKIP_AUTO_CLEANUP),
// dom.debug()
'process.env.DEBUG_PRINT_LIMIT': process.env.DEBUG_PRINT_LIMIT || '7000',
},
plugins: [
{
name: 'test-utils-rewrite',
Expand Down
4 changes: 4 additions & 0 deletions test/browser/test/another.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ import { expect, it } from 'vitest'
it('basic 3', async () => {
expect(globalThis.window).toBeDefined()
})

it('no process', () => {
expect(globalThis.process).toBeUndefined()
})

0 comments on commit 1affb99

Please sign in to comment.