diff --git a/packages/client/package.json b/packages/client/package.json index fb9851e0a1..073869415d 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -15,8 +15,8 @@ "./manifest.json": "./manifest.json" }, "scripts": { - "build": "rollup -c", - "dev": "rollup -cw" + "build": "vite build", + "dev": "vite build --watch" }, "dependencies": { "@budibase/bbui": "0.0.0", @@ -36,19 +36,9 @@ "svelte-spa-router": "^4.0.1" }, "devDependencies": { - "@rollup/plugin-alias": "^5.1.0", - "@rollup/plugin-commonjs": "^25.0.7", - "@rollup/plugin-image": "^3.0.3", - "@rollup/plugin-node-resolve": "^15.2.3", - "postcss": "^8.4.35", - "rollup": "^4.9.6", - "rollup-plugin-json": "^4.0.0", - "rollup-plugin-polyfill-node": "^0.13.0", - "rollup-plugin-postcss": "^4.0.2", - "rollup-plugin-svelte": "^7.1.6", - "rollup-plugin-svg": "^2.0.0", - "rollup-plugin-terser": "^7.0.2", - "rollup-plugin-visualizer": "^5.12.0" + "@sveltejs/vite-plugin-svelte": "1.4.0", + "vite": "^4.5.0", + "vite-plugin-css-injected-by-js": "3.5.2" }, "resolutions": { "loader-utils": "1.4.1" diff --git a/packages/client/rollup.config.js b/packages/client/rollup.config.js deleted file mode 100644 index 9839414f7e..0000000000 --- a/packages/client/rollup.config.js +++ /dev/null @@ -1,117 +0,0 @@ -import commonjs from "@rollup/plugin-commonjs" -import resolve from "@rollup/plugin-node-resolve" -import alias from "@rollup/plugin-alias" -import svelte from "rollup-plugin-svelte" -import { terser } from "rollup-plugin-terser" -import postcss from "rollup-plugin-postcss" -import svg from "rollup-plugin-svg" -import image from "@rollup/plugin-image" -import json from "rollup-plugin-json" -import nodePolyfills from "rollup-plugin-polyfill-node" -import path from "path" -import { visualizer } from "rollup-plugin-visualizer" - -const production = !process.env.ROLLUP_WATCH -const ignoredWarnings = [ - "unused-export-let", - "css-unused-selector", - "module-script-reactive-declaration", - "a11y-no-onchange", - "a11y-click-events-have-key-events", -] - -const devPaths = production - ? [] - : [ - { - find: "@budibase/shared-core", - replacement: path.resolve("../shared-core/dist/index"), - }, - { - find: "@budibase/types", - replacement: path.resolve("../types/dist/index"), - }, - ] - -export default { - input: "src/index.js", - output: [ - { - sourcemap: false, - format: "iife", - file: `./dist/budibase-client.js`, - }, - ], - onwarn(warning, warn) { - if ( - warning.code === "THIS_IS_UNDEFINED" || - warning.code === "CIRCULAR_DEPENDENCY" || - warning.code === "EVAL" - ) { - return - } - warn(warning) - }, - plugins: [ - alias({ - entries: [ - { - find: "manifest.json", - replacement: path.resolve("./manifest.json"), - }, - { - find: "api", - replacement: path.resolve("./src/api"), - }, - { - find: "components", - replacement: path.resolve("./src/components"), - }, - { - find: "stores", - replacement: path.resolve("./src/stores"), - }, - { - find: "utils", - replacement: path.resolve("./src/utils"), - }, - { - find: "constants", - replacement: path.resolve("./src/constants"), - }, - { - find: "sdk", - replacement: path.resolve("./src/sdk"), - }, - ...devPaths, - ], - }), - svelte({ - emitCss: true, - onwarn: (warning, handler) => { - // Ignore some warnings - if (!ignoredWarnings.includes(warning.code)) { - handler(warning) - } - }, - }), - postcss(), - commonjs(), - nodePolyfills(), - resolve({ - preferBuiltins: true, - browser: true, - dedupe: ["svelte", "svelte/internal"], - }), - svg(), - image({ - exclude: "**/*.svg", - }), - json(), - production && terser(), - !production && visualizer(), - ], - watch: { - clearScreen: false, - }, -} diff --git a/packages/client/src/index.js b/packages/client/src/index.js index de6d1bdc12..9cef52bb1e 100644 --- a/packages/client/src/index.js +++ b/packages/client/src/index.js @@ -10,7 +10,7 @@ import { eventStore, hoverStore, } from "./stores" -import loadSpectrumIcons from "@budibase/bbui/spectrum-icons-rollup.js" +import loadSpectrumIcons from "@budibase/bbui/spectrum-icons-vite.js" import { get } from "svelte/store" import { initWebsocket } from "./websocket.js" diff --git a/packages/client/tsconfig.json b/packages/client/tsconfig.json index 81f1657f48..740b129738 100644 --- a/packages/client/tsconfig.json +++ b/packages/client/tsconfig.json @@ -3,6 +3,10 @@ "allowJs": true, "strict": true, "outDir": "dist", + "allowSyntheticDefaultImports": true, + "target": "ESNext", + "moduleResolution": "bundler", + "resolveJsonModule": true, "paths": { "@budibase/*": [ "../*/src/index.ts", @@ -12,6 +16,5 @@ ], "*": ["./src/*"] } - }, - "include": ["src/**/*"] + } } diff --git a/packages/client/vite.config.mjs b/packages/client/vite.config.mjs new file mode 100644 index 0000000000..9c623b709f --- /dev/null +++ b/packages/client/vite.config.mjs @@ -0,0 +1,89 @@ +import { svelte } from "@sveltejs/vite-plugin-svelte" +import { defineConfig } from "vite" +import path from "path" +import cssInjectedByJsPlugin from "vite-plugin-css-injected-by-js" + +const ignoredWarnings = [ + "unused-export-let", + "css-unused-selector", + "module-script-reactive-declaration", + "a11y-no-onchange", + "a11y-click-events-have-key-events", +] + +export default defineConfig(({ mode }) => { + const isProduction = mode === "production" + + return { + server: { + open: false, + }, + build: { + lib: { + entry: "src/index.js", + formats: ["iife"], + outDir: "dist", + name: "budibase_client", + fileName: () => "budibase-client.js", + minify: isProduction, + }, + }, + plugins: [ + svelte({ + emitCss: true, + onwarn: (warning, handler) => { + // Ignore some warnings + if (!ignoredWarnings.includes(warning.code)) { + handler(warning) + } + }, + }), + cssInjectedByJsPlugin(), + ], + resolve: { + dedupe: ["svelte", "svelte/internal"], + alias: [ + { + find: "manifest.json", + replacement: path.resolve("./manifest.json"), + }, + { + find: "api", + replacement: path.resolve("./src/api"), + }, + { + find: "components", + replacement: path.resolve("./src/components"), + }, + { + find: "stores", + replacement: path.resolve("./src/stores"), + }, + { + find: "utils", + replacement: path.resolve("./src/utils"), + }, + { + find: "constants", + replacement: path.resolve("./src/constants"), + }, + { + find: "sdk", + replacement: path.resolve("./src/sdk"), + }, + { + find: "@budibase/types", + replacement: path.resolve("../types/src"), + }, + { + find: "@budibase/shared-core", + replacement: path.resolve("../shared-core/src"), + }, + { + find: "@budibase/bbui", + replacement: path.resolve("../bbui/src"), + }, + ], + }, + } +}) diff --git a/yarn.lock b/yarn.lock index 80f16566f2..edf81d1f1e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4075,13 +4075,6 @@ resolved "https://registry.yarnpkg.com/@redis/time-series/-/time-series-1.0.4.tgz#af85eb080f6934580e4d3b58046026b6c2b18717" integrity sha512-ThUIgo2U/g7cCuZavucQTQzA9g9JbDDY2f64u3AbAoz/8vE2lt2U37LamDUVChhaDA3IRT9R6VvJwqnUfTJzng== -"@rollup/plugin-alias@^5.1.0": - version "5.1.0" - resolved "https://registry.yarnpkg.com/@rollup/plugin-alias/-/plugin-alias-5.1.0.tgz#99a94accc4ff9a3483be5baeedd5d7da3b597e93" - integrity sha512-lpA3RZ9PdIG7qqhEfv79tBffNaoDuukFDrmhLqg9ifv99u/ehn+lOg30x2zmhf8AQqQUZaMk/B9fZraQ6/acDQ== - dependencies: - slash "^4.0.0" - "@rollup/plugin-commonjs@^16.0.0": version "16.0.0" resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-16.0.0.tgz#169004d56cd0f0a1d0f35915d31a036b0efe281f" @@ -4120,14 +4113,6 @@ is-reference "1.2.1" magic-string "^0.30.3" -"@rollup/plugin-image@^3.0.3": - version "3.0.3" - resolved "https://registry.yarnpkg.com/@rollup/plugin-image/-/plugin-image-3.0.3.tgz#025b557180bae20f2349ff5130ef2114169feaac" - integrity sha512-qXWQwsXpvD4trSb8PeFPFajp8JLpRtqqOeNYRUKnEQNHm7e5UP7fuSRcbjQAJ7wDZBbnJvSdY5ujNBQd9B1iFg== - dependencies: - "@rollup/pluginutils" "^5.0.1" - mini-svg-data-uri "^1.4.4" - "@rollup/plugin-inject@^5.0.4", "@rollup/plugin-inject@^5.0.5": version "5.0.5" resolved "https://registry.yarnpkg.com/@rollup/plugin-inject/-/plugin-inject-5.0.5.tgz#616f3a73fe075765f91c5bec90176608bed277a3" @@ -10885,11 +10870,6 @@ estraverse@^5.1.0, estraverse@^5.2.0: resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== -estree-walker@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.2.1.tgz#bdafe8095383d8414d5dc2ecf4c9173b6db9412e" - integrity sha512-6/I1dwNKk0N9iGOU3ydzAAurz4NPo/ttxZNCqgIVbWFvWyzWBSNonRrJ5CpjDuyBfmM7ENN7WCzUi9aT/UPXXQ== - estree-walker@^0.5.2: version "0.5.2" resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.5.2.tgz#d3850be7529c9580d815600b53126515e146dd39" @@ -15653,11 +15633,6 @@ min-indent@^1.0.0: resolved "https://registry.yarnpkg.com/min-indent/-/min-indent-1.0.1.tgz#a63f681673b30571fbe8bc25686ae746eefa9869" integrity sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg== -mini-svg-data-uri@^1.4.4: - version "1.4.4" - resolved "https://registry.yarnpkg.com/mini-svg-data-uri/-/mini-svg-data-uri-1.4.4.tgz#8ab0aabcdf8c29ad5693ca595af19dd2ead09939" - integrity sha512-r9deDe9p5FJUPZAk3A59wGH7Ii9YrjjWw0jmw/liSbHl2CHiyXj6FcDXDu2K3TjVAXqiJdaw3xxwlZZr9E6nHg== - minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" @@ -15668,7 +15643,7 @@ minimalistic-crypto-utils@^1.0.1: resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" integrity sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg== -"minimatch@2 || 3", minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2: +"minimatch@2 || 3", minimatch@^3.0.3, minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== @@ -17924,7 +17899,7 @@ postcss-values-parser@^6.0.2: is-url-superb "^4.0.0" quote-unquote "^1.0.0" -postcss@^8.1.7, postcss@^8.2.9, postcss@^8.3.11, postcss@^8.4.12, postcss@^8.4.27, postcss@^8.4.29, postcss@^8.4.35, postcss@^8.4.5: +postcss@^8.1.7, postcss@^8.2.9, postcss@^8.3.11, postcss@^8.4.12, postcss@^8.4.27, postcss@^8.4.29, postcss@^8.4.5: version "8.4.41" resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.41.tgz#d6104d3ba272d882fe18fc07d15dc2da62fa2681" integrity sha512-TesUflQ0WKZqAvg52PWL6kHgLKP6xB6heTOdoYM0Wt2UHyxNa4K25EZZMgKns3BH1RLVbZCREPpLY0rhnNoHVQ== @@ -19245,13 +19220,6 @@ rollup-plugin-inject-process-env@^1.3.1: dependencies: magic-string "^0.25.7" -rollup-plugin-json@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-json/-/rollup-plugin-json-4.0.0.tgz#a18da0a4b30bf5ca1ee76ddb1422afbb84ae2b9e" - integrity sha512-hgb8N7Cgfw5SZAkb3jf0QXii6QX/FOkiIq2M7BAQIEydjHvTyxXHQiIzZaTFgx1GK0cRCHOCBHIyEkkLdWKxow== - dependencies: - rollup-pluginutils "^2.5.0" - rollup-plugin-node-builtins@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/rollup-plugin-node-builtins/-/rollup-plugin-node-builtins-2.1.2.tgz#24a1fed4a43257b6b64371d8abc6ce1ab14597e9" @@ -19292,7 +19260,7 @@ rollup-plugin-polyfill-node@^0.13.0: dependencies: "@rollup/plugin-inject" "^5.0.4" -rollup-plugin-postcss@^4.0.0, rollup-plugin-postcss@^4.0.2: +rollup-plugin-postcss@^4.0.0: version "4.0.2" resolved "https://registry.yarnpkg.com/rollup-plugin-postcss/-/rollup-plugin-postcss-4.0.2.tgz#15e9462f39475059b368ce0e49c800fa4b1f7050" integrity sha512-05EaY6zvZdmvPUDi3uCcAQoESDcYnv8ogJJQRp6V5kZ6J6P7uAVJlrTZcaaA20wTH527YTnKfkAoPxWI/jPp4w== @@ -19311,7 +19279,7 @@ rollup-plugin-postcss@^4.0.0, rollup-plugin-postcss@^4.0.2: safe-identifier "^0.4.2" style-inject "^0.3.0" -rollup-plugin-svelte@^7.1.0, rollup-plugin-svelte@^7.1.6: +rollup-plugin-svelte@^7.1.0: version "7.1.6" resolved "https://registry.yarnpkg.com/rollup-plugin-svelte/-/rollup-plugin-svelte-7.1.6.tgz#44a4ea6c6e8ed976824d9fd40c78d048515e5838" integrity sha512-nVFRBpGWI2qUY1OcSiEEA/kjCY2+vAjO9BI8SzA7NRrh2GTunLd6w2EYmnMt/atgdg8GvcNjLsmZmbQs/u4SQA== @@ -19319,13 +19287,6 @@ rollup-plugin-svelte@^7.1.0, rollup-plugin-svelte@^7.1.6: "@rollup/pluginutils" "^4.1.0" resolve.exports "^2.0.0" -rollup-plugin-svg@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-svg/-/rollup-plugin-svg-2.0.0.tgz#ce11b55e915d5b2190328c4e6632bd6b4fe12ee9" - integrity sha512-DmE7dSQHo1SC5L2uH2qul3Mjyd5oV6U1aVVkyvTLX/mUsRink7f1b1zaIm+32GEBA6EHu8H/JJi3DdWqM53ySQ== - dependencies: - rollup-pluginutils "^1.3.1" - rollup-plugin-terser@^7.0.2: version "7.0.2" resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz#e8fbba4869981b2dc35ae7e8a502d5c6c04d324d" @@ -19336,30 +19297,12 @@ rollup-plugin-terser@^7.0.2: serialize-javascript "^4.0.0" terser "^5.0.0" -rollup-plugin-visualizer@^5.12.0: - version "5.12.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-visualizer/-/rollup-plugin-visualizer-5.12.0.tgz#661542191ce78ee4f378995297260d0c1efb1302" - integrity sha512-8/NU9jXcHRs7Nnj07PF2o4gjxmm9lXIrZ8r175bT9dK8qoLlvKTwRMArRCMgpMGlq8CTLugRvEmyMeMXIU2pNQ== - dependencies: - open "^8.4.0" - picomatch "^2.3.1" - source-map "^0.7.4" - yargs "^17.5.1" - rollup-plugin-web-worker-loader@^1.6.1: version "1.6.1" resolved "https://registry.yarnpkg.com/rollup-plugin-web-worker-loader/-/rollup-plugin-web-worker-loader-1.6.1.tgz#9d7a27575b64b0780fe4e8b3bc87470d217e485f" integrity sha512-4QywQSz1NXFHKdyiou16mH3ijpcfLtLGOrAqvAqu1Gx+P8+zj+3gwC2BSL/VW1d+LW4nIHC8F7d7OXhs9UdR2A== -rollup-pluginutils@^1.3.1: - version "1.5.2" - resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-1.5.2.tgz#1e156e778f94b7255bfa1b3d0178be8f5c552408" - integrity sha512-SjdWWWO/CUoMpDy8RUbZ/pSpG68YHmhk5ROKNIoi2En9bJ8bTt3IhYi254RWiTclQmL7Awmrq+rZFOhZkJAHmQ== - dependencies: - estree-walker "^0.2.1" - minimatch "^3.0.2" - -rollup-pluginutils@^2.3.1, rollup-pluginutils@^2.5.0, rollup-pluginutils@^2.8.1, rollup-pluginutils@^2.8.2: +rollup-pluginutils@^2.3.1, rollup-pluginutils@^2.8.1, rollup-pluginutils@^2.8.2: version "2.8.2" resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e" integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ== @@ -19817,11 +19760,6 @@ slash@3.0.0, slash@^3.0.0: resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== -slash@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/slash/-/slash-4.0.0.tgz#2422372176c4c6c5addb5e2ada885af984b396a7" - integrity sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew== - slice-ansi@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-5.0.0.tgz#b73063c57aa96f9cd881654b15294d95d285c42a" @@ -21897,6 +21835,11 @@ vite-node@0.29.8: picocolors "^1.0.0" vite "^3.0.0 || ^4.0.0" +vite-plugin-css-injected-by-js@3.5.2: + version "3.5.2" + resolved "https://registry.yarnpkg.com/vite-plugin-css-injected-by-js/-/vite-plugin-css-injected-by-js-3.5.2.tgz#1f75d16ad5c05b6b49bf18018099a189ec2e46ad" + integrity sha512-2MpU/Y+SCZyWUB6ua3HbJCrgnF0KACAsmzOQt1UvRVJCGF6S8xdA3ZUhWcWdM9ivG4I5az8PnQmwwrkC2CAQrQ== + vite-plugin-static-copy@^0.17.0: version "0.17.0" resolved "https://registry.yarnpkg.com/vite-plugin-static-copy/-/vite-plugin-static-copy-0.17.0.tgz#e45527da186c4a3818d09635797b6fc7cc9e035f" @@ -22534,7 +22477,7 @@ yargs@16.2.0, yargs@^16.1.0, yargs@^16.2.0: y18n "^5.0.5" yargs-parser "^20.2.2" -yargs@^17.3.1, yargs@^17.5.1, yargs@^17.6.2, yargs@^17.7.2: +yargs@^17.3.1, yargs@^17.6.2, yargs@^17.7.2: version "17.7.2" resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269" integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==