From 89f8af487445d2cd4ce0a8d739134f3cc62f7f29 Mon Sep 17 00:00:00 2001 From: relliv Date: Mon, 4 Nov 2024 21:47:37 +0300 Subject: [PATCH] Fix bundle size issue --- .../nx-calendar-heatmap-utils/package.json | 2 +- .../nx-calendar-heatmap-utils/vite.config.ts | 48 +++++++++++-------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/libs/utils/nx-calendar-heatmap-utils/package.json b/libs/utils/nx-calendar-heatmap-utils/package.json index 9b3cdb7..eaffbfb 100644 --- a/libs/utils/nx-calendar-heatmap-utils/package.json +++ b/libs/utils/nx-calendar-heatmap-utils/package.json @@ -1,6 +1,6 @@ { "name": "@ngeenx/nx-calendar-heatmap-utils", - "version": "1.0.1", + "version": "1.0.2", "description": "NX Calendar Heatmap component utils", "keywords": [ "calendar utils", diff --git a/libs/utils/nx-calendar-heatmap-utils/vite.config.ts b/libs/utils/nx-calendar-heatmap-utils/vite.config.ts index 6a2db0e..564056f 100644 --- a/libs/utils/nx-calendar-heatmap-utils/vite.config.ts +++ b/libs/utils/nx-calendar-heatmap-utils/vite.config.ts @@ -1,19 +1,19 @@ /// -import { defineConfig } from 'vite'; -import dts from 'vite-plugin-dts'; -import * as path from 'path'; -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; -import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin'; +import { defineConfig } from "vite"; +import dts from "vite-plugin-dts"; +import * as path from "path"; +import { nxViteTsPaths } from "@nx/vite/plugins/nx-tsconfig-paths.plugin"; +import { nxCopyAssetsPlugin } from "@nx/vite/plugins/nx-copy-assets.plugin"; export default defineConfig({ root: __dirname, - cacheDir: '../../../node_modules/.vite/libs/utils/nx-calendar-heatmap-utils', + cacheDir: "../../../node_modules/.vite/libs/utils/nx-calendar-heatmap-utils", plugins: [ nxViteTsPaths(), - nxCopyAssetsPlugin(['*.md']), + nxCopyAssetsPlugin(["*.md"]), dts({ - entryRoot: 'src', - tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'), + entryRoot: "src", + tsconfigPath: path.join(__dirname, "tsconfig.lib.json"), }), ], // Uncomment this if you are using workers. @@ -23,7 +23,7 @@ export default defineConfig({ // Configuration for building your library. // See: https://vitejs.dev/guide/build.html#library-mode build: { - outDir: '../../../dist/libs/utils/nx-calendar-heatmap-utils', + outDir: "../../../dist/libs/utils/nx-calendar-heatmap-utils", emptyOutDir: true, reportCompressedSize: true, commonjsOptions: { @@ -31,28 +31,36 @@ export default defineConfig({ }, lib: { // Could also be a dictionary or array of multiple entry points. - entry: 'src/index.ts', - name: 'nx-calendar-heatmap-utils', - fileName: 'index', + entry: "src/index.ts", + name: "nx-calendar-heatmap-utils", + fileName: "index", // Change this to the formats you want to support. // Don't forget to update your package.json as well. - formats: ['es', 'cjs'], + formats: ["es", "cjs"], }, rollupOptions: { // External packages that should not be bundled into your library. - external: [], + external: ["tippy.js", "luxon"], + output: { + // Provide global variables to use in the UMD build + // for externalized deps + globals: { + "tippy.js": "tippy", + luxon: "luxon", + }, + }, }, }, test: { watch: false, globals: true, - environment: 'node', - include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], - reporters: ['default'], + environment: "node", + include: ["src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"], + reporters: ["default"], coverage: { reportsDirectory: - '../../../coverage/libs/utils/nx-calendar-heatmap-utils', - provider: 'v8', + "../../../coverage/libs/utils/nx-calendar-heatmap-utils", + provider: "v8", }, }, });