Closed rabraghib closed 2 months ago
This can be resolved with the vite-plugin-node-polyfills
package.
npm i vite-plugin-node-polyfills --save-dev
And update the vite config
/// <reference types="vitest" />
import { defineConfig } from 'vite';
import analog from '@analogjs/platform';
import { nodePolyfills } from 'vite-plugin-node-polyfills'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
build: {
target: ['es2020'],
},
resolve: {
mainFields: ['module'],
},
plugins: [
analog(),
nodePolyfills(),
],
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['src/test-setup.ts'],
include: ['**/*.spec.ts'],
reporters: ['default'],
},
define: {
'import.meta.vitest': mode !== 'production',
},
}));
You might see a build error logged to the console at the end, but the server runs correctly.
Reference: https://github.com/vitejs/vite/discussions/8799#discussioncomment-6240272
Please provide the environment you discovered this bug in.
https://github.com/rabraghib/analog-algoliasearch-bug
Which area/package is the issue in?
vite-plugin-angular
Description
When using the
algoliasearch/lite
package in an AnalogJS project, the build process (npm run build
) fails. However, the project runs as expected in development mode (npm run dev
).Nothing is generated in the output folder when the build fails. It seems like the client build phase doesn't generate an output and the SSR build phase throws an error.
I've tried adding
algoliasearch
andalgoliasearch/lite
to thenoExternal
configuration invite.config.js
but did not fix the problem:Please provide the exception or error you saw
Other information
No response
I would be willing to submit a PR to fix this issue