Skip to content

Commit

Permalink
fix(browser): don't polyfill process.env (#6718)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va authored Oct 15, 2024
1 parent 2e6aa64 commit da6d2ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
15 changes: 0 additions & 15 deletions packages/browser/src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,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 @@ -388,24 +387,10 @@ export default (browserServer: BrowserServer, base = '/'): Plugin[] => {
}
},
},
// TODO: remove this when @testing-library/vue supports ESM
{
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: {
plugins: [
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 da6d2ea

Please sign in to comment.