Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/vite-plugin-cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
},
"dependencies": {
"@hattip/adapter-node": "^0.0.49",
"@rollup/plugin-replace": "^6.0.1",
"miniflare": "^3.20241205.0"
},
"devDependencies": {
Expand Down
8 changes: 8 additions & 0 deletions packages/vite-plugin-cloudflare/src/cloudflare-environment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import assert from 'node:assert';
import { builtinModules } from 'node:module';
import replace from '@rollup/plugin-replace';
import * as vite from 'vite';
import { getNodeCompatExternals } from './node-js-compat';
import { INIT_PATH, UNKNOWN_HOST } from './shared';
Expand Down Expand Up @@ -153,6 +154,13 @@ export function createCloudflareEnvironmentOptions(
// optimizeDeps.entries in the dev config)
input: workerConfig.main,
external: [...cloudflareBuiltInModules, ...getNodeCompatExternals()],
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify(
process.env.NODE_ENV ?? 'production',
),
}),
],
},
},
optimizeDeps: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ describe('module resolution', async () => {
* special meaning to us.
*/
describe('third party packages resolutions', () => {
// TODO: we skip this test on build because a `ReferenceError: process is not defined` is thrown
// (https://github.com/flarelabs-net/vite-plugin-cloudflare/issues/82)
test.skipIf(isBuild)('react', async () => {
test('react', async () => {
const result = await getJsonResponse('/third-party/react');
expect(result).toEqual({
'(react) reactVersionsMatch': true,
Expand Down
41 changes: 41 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.