From 85ce25bb5546a69d3847933adb2759b4907208f7 Mon Sep 17 00:00:00 2001 From: Jhmeel Date: Sat, 14 Sep 2024 16:36:37 +0100 Subject: [PATCH] updates --- .babelrc | 7 ++----- package-lock.json | 27 +++++++++++++++++++++++++++ package.json | 1 + vite.config.ts | 31 +++++++++++++++++++++++++++---- 4 files changed, 57 insertions(+), 9 deletions(-) diff --git a/.babelrc b/.babelrc index 77ee57b..985d672 100644 --- a/.babelrc +++ b/.babelrc @@ -1,7 +1,4 @@ { "presets": ["@babel/preset-env", "@babel/preset-react"], - "plugins": [ - "@babel/plugin-transform-modules-commonjs", - "@babel/plugin-transform-runtime" - ] -} + "plugins": ["@babel/plugin-transform-runtime"] +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 90534c5..f5453eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "@mui/material": "^5.16.7", "@mui/styled-engine-sc": "^6.0.0-alpha.18", "@mui/x-data-grid": "^7.12.1", + "@rollup/plugin-babel": "^6.0.4", "@rollup/plugin-commonjs": "^26.0.1", "@swc/core": "^1.7.22", "@tbdex/http-client": "^1.1.0", @@ -4451,6 +4452,32 @@ "node": ">=14.0.0" } }, + "node_modules/@rollup/plugin-babel": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-6.0.4.tgz", + "integrity": "sha512-YF7Y52kFdFT/xVSuVdjkV5ZdX/3YtmX0QulG+x0taQOtJdHYzVU61aSSkAgVJ7NOv6qPkIYiJSgSWWN/DM5sGw==", + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.18.6", + "@rollup/pluginutils": "^5.0.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0", + "@types/babel__core": "^7.1.9", + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "@types/babel__core": { + "optional": true + }, + "rollup": { + "optional": true + } + } + }, "node_modules/@rollup/plugin-commonjs": { "version": "26.0.1", "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-26.0.1.tgz", diff --git a/package.json b/package.json index dd5f741..cad177c 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "@mui/material": "^5.16.7", "@mui/styled-engine-sc": "^6.0.0-alpha.18", "@mui/x-data-grid": "^7.12.1", + "@rollup/plugin-babel": "^6.0.4", "@rollup/plugin-commonjs": "^26.0.1", "@swc/core": "^1.7.22", "@tbdex/http-client": "^1.1.0", diff --git a/vite.config.ts b/vite.config.ts index cad24b3..d31b1ba 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,21 +2,32 @@ import { defineConfig } from "vite"; import react from "@vitejs/plugin-react-swc"; import commonjs from "@rollup/plugin-commonjs"; import { nodePolyfills } from "vite-plugin-node-polyfills"; +import { visualizer } from "rollup-plugin-visualizer"; +import { babel } from '@rollup/plugin-babel'; export default defineConfig({ plugins: [ react(), + babel({ + babelHelpers: 'bundled', + presets: ['@babel/preset-env', '@babel/preset-react'], + plugins: ['@babel/plugin-transform-runtime'], + exclude: 'node_modules/**', + }), commonjs({ requireReturnsDefault: 'auto', include: [ /node_modules/, /\/node_modules\/@tbdex\/http-client/, /\/node_modules\/@web5\/dids/, + /\/node_modules\/multiformats/, ], + transformMixedEsModules: true, }), nodePolyfills({ protocolImports: true, }), + visualizer(), ], resolve: { alias: { @@ -27,19 +38,31 @@ export default defineConfig({ http: "stream-http", https: "https-browserify", buffer: "buffer", + process: "process/browser", }, }, build: { + commonjsOptions: { + transformMixedEsModules: true, + include: [/node_modules/], + }, rollupOptions: { - plugins: [commonjs()], + output: { + manualChunks: { + vendor: ['react', 'react-dom', 'ethers'], + tbdex: ['@tbdex/http-client'], + web5: ['@web5/dids'], + }, + }, }, + sourcemap: true, }, define: { - "process.env": {}, - global: "globalThis", + 'process.env': {}, + global: 'globalThis', }, optimizeDeps: { - include: ['react', 'react-dom', 'ethers', '@tbdex/http-client', '@web5/dids'], + include: ['react', 'react-dom', 'ethers', '@tbdex/http-client', '@web5/dids', 'multiformats'], esbuildOptions: { target: 'esnext', supported: { bigint: true },