Skip to content

Commit

Permalink
refactor: switch to modern polyfills vite plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
dschmidt committed Apr 17, 2024
1 parent a8ae923 commit 5fa66fb
Show file tree
Hide file tree
Showing 6 changed files with 431 additions and 65 deletions.
9 changes: 0 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
<meta http-equiv="x-ua-compatible" content="IE=edge" />

<title><%= data.title %></title>
<script>
window.global = window
</script>
<link rel="manifest" href="manifest.json" crossorigin="use-credentials" />
<% if (data.buildConfig.cdn) { %>
<script src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script>
Expand All @@ -22,12 +19,6 @@
<script src="js/require.js?<%= data.compilationTimestamp %>"></script>
<% } %>
<script type="module" src="./packages/web-runtime/src/index.ts"></script>
<script type="module">
// Fix Buffer usage in production (!)
// If single file downloads work in production after removing this, it can probably be removed permanently
import { Buffer } from 'buffer'
window.Buffer = Buffer
</script>
<link rel="stylesheet" href="./packages/design-system/src/styles/stylesWrapper.scss" />
<style>
html,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
"qs": "6.11.2",
"react": "17.0.2",
"requirejs": "2.3.6",
"rollup-plugin-node-polyfills": "0.2.1",
"rollup-plugin-visualizer": "5.9.0",
"sass": "1.69.7",
"ts-node": "10.9.2",
Expand All @@ -102,6 +101,7 @@
"url-search-params-polyfill": "8.1.1",
"vite": "5.2.8",
"vite-plugin-environment": "^1.1.3",
"vite-plugin-node-polyfills": "0.21.0",
"vitest": "1.4.0",
"vitest-mock-extended": "1.3.1",
"vue-tsc": "1.8.27",
Expand Down
1 change: 0 additions & 1 deletion packages/extension-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
},
"dependencies": {
"@vitejs/plugin-vue": "^4.0.0",
"rollup-plugin-node-polyfills": "^0.2.1",
"rollup-plugin-serve": "^2.0.2"
},
"peerDependencies": {
Expand Down
17 changes: 8 additions & 9 deletions packages/web-client/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import { join, resolve } from 'path'
import { defineConfig, searchForWorkspaceRoot } from 'vite'
import dts from 'vite-plugin-dts'
import { nodePolyfills } from 'vite-plugin-node-polyfills'

const projectRootDir = searchForWorkspaceRoot(process.cwd())

export default defineConfig({
resolve: {
alias: {
path: 'rollup-plugin-node-polyfills/polyfills/path',
crypto: join(projectRootDir, 'polyfills/crypto.js'),
stream: 'rollup-plugin-node-polyfills/polyfills/stream',
string_decoder: 'rollup-plugin-node-polyfills/polyfills/string-decoder',
util: 'rollup-plugin-node-polyfills/polyfills/util',
buffer: 'rollup-plugin-node-polyfills/polyfills/buffer-es6',
process: 'rollup-plugin-node-polyfills/polyfills/process-es6',
events: 'rollup-plugin-node-polyfills/polyfills/events'
crypto: join(projectRootDir, 'polyfills/crypto.js')
}
},
build: {
Expand All @@ -29,5 +23,10 @@ export default defineConfig({
}
}
},
plugins: [dts()]
plugins: [
nodePolyfills({
exclude: ['crypto']
}),
dts()
]
})
Loading

0 comments on commit 5fa66fb

Please sign in to comment.