Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polyfills #1333

Merged
merged 7 commits into from Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions frontend-html/package.json
Expand Up @@ -92,6 +92,8 @@
"@babel/preset-env": "^7.20.2",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
"@types/react-beautiful-dnd": "^13.1.2",
"@types/uuid": "^9.0.0",
"@vitejs/plugin-react": "^3.0.1",
Expand Down
Expand Up @@ -70,6 +70,7 @@ export default class ColorEditor extends React.Component<{
machine = interpret(
createMachine(
{
predictableActionArguments: true,
id: "colorEditor",
type: "parallel",
states: {
Expand Down
Expand Up @@ -61,6 +61,7 @@ export class UpdateRequestAggregator {
interpreter = interpret(
createMachine(
{
predictableActionArguments: true,
id: "updateObject",
initial: "IDLE",
states: {
Expand Down
1 change: 1 addition & 0 deletions frontend-html/src/utils/PeriodicLoader.ts
Expand Up @@ -31,6 +31,7 @@ export class PeriodicLoader {
interpreter = interpret(
createMachine(
{
predictableActionArguments: true,
id: "periodicLoader",
initial: "INITIALIZED",
states: {
Expand Down
1 change: 1 addition & 0 deletions frontend-html/src/utils/mouse.ts
Expand Up @@ -23,6 +23,7 @@ export function preventDoubleclickSelect() {
const interpreter = interpret(
createMachine(
{
predictableActionArguments: true,
id: "selectionPreventer",
initial: "IDLE",
states: {
Expand Down
36 changes: 35 additions & 1 deletion frontend-html/vite.config.ts
Expand Up @@ -2,6 +2,9 @@ import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tsconfigPaths from 'vite-tsconfig-paths'
import basicSsl from '@vitejs/plugin-basic-ssl'
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill'
import rollupNodePolyFill from 'rollup-plugin-node-polyfills'

// https://vitejs.dev/config/
export default defineConfig({
Expand Down Expand Up @@ -34,17 +37,48 @@ export default defineConfig({
find: 'stream',
replacement: `stream-browserify`,
},
{
find: 'events',
replacement: 'rollup-plugin-node-polyfills/polyfills/events',
},
{
find: 'buffer',
replacement: 'rollup-plugin-node-polyfills/polyfills/buffer-es6',
}
],
},
css:{
modules: {
generateScopedName: "[name]__[local]__[hash:base64:2]"
}
},
optimizeDeps: {
esbuildOptions: {
// Node.js global to browser globalThis
define: {
global: 'globalThis'
},
// Enable esbuild polyfill plugins
plugins: [
NodeGlobalsPolyfillPlugin({
process: true,
buffer: true
}),
NodeModulesPolyfillPlugin()
]
}
},
build: {
commonjsOptions: {
transformMixedEsModules: true
}
},
rollupOptions: {
plugins: [
// Enable rollup polyfills plugin
// used during production bundling
rollupNodePolyFill(),
],
},
},
server: {
https: true,
Expand Down