Skip to content

Commit

Permalink
feat: use vite's build
Browse files Browse the repository at this point in the history
Signed-off-by: Ivaylo Nikolov <ivaylo.nikolov@limechain.tech>
  • Loading branch information
ivaylonikolov7 committed Feb 17, 2025
1 parent 5abbee4 commit d8e133e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 6 deletions.
1 change: 1 addition & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ tasks:
- task: format
- task: lint
- npx babel src -d lib --out-file-extension .cjs > /dev/null
- npx vite build > /dev/null
- npx yalc publish > /dev/null

clean:
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"./package.json": "./package.json",
".": {
"types": "./lib/index.d.ts",
"import": "./src/index.js",
"import": "./lib/index.js",
"require": "./lib/index.cjs"
}
},
Expand Down Expand Up @@ -119,6 +119,7 @@
"typedoc": "^0.27.6",
"typescript": "^5.7.2",
"vite": "^6.1.0",
"vite-bundle-analyzer": "^0.17.0",
"yalc": "1.0.0-pre.53"
},
"peerDependencies": {
Expand Down
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 34 additions & 5 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
import path from "path";

import { analyzer } from "vite-bundle-analyzer";

/** @type {import('vite').UserConfig} */
export default {
plugins: [analyzer()],
server: {
hmr: false,
},
envDir: "./",
build: {
polyfillDynamicImport: false,
lib: {
entry: path.resolve(__dirname, "src/index.js"),
formats: ["es"],
fileName: (format) => `[name].js`,
},
rollupOptions: {
external: [], // Add external dependencies here if any
output: {
preserveModules: true,
preserveModulesRoot: "src",
entryFileNames: "[name].js",
},
},
minify: "terser",
terserOptions: {
keep_classnames: true,
keep_fnames: true,
},
sourcemap: true,
outDir: "lib",
},
optimizeDeps: {
force: true,
Expand All @@ -29,9 +54,10 @@ export default {
// will take care of this
"../../src/index.js": "../../src/browser.js",
"../src/index.js": "../src/browser.js",
// TODO: extract `encoding/hex.js` etc into a variable and call a function to generate
// TODO: extract `encoding/hex.js` etc into a variable and call a function to generate
// all the prefixes.
"../../../src/encoding/hex.js": "../../../src/encoding/hex.browser.js",
"../../../src/encoding/hex.js":
"../../../src/encoding/hex.browser.js",
"../../src/encoding/hex.js": "../../src/encoding/hex.browser.js",
"../src/encoding/hex.js": "../src/encoding/hex.browser.js",
"src/encoding/hex.js": "src/encoding/hex.browser.js",
Expand All @@ -40,10 +66,13 @@ export default {
"../src/encoding/utf8.js": "../src/encoding/utf8.browser.js",
"../../src/encoding/utf8.js": "../../src/encoding/utf8.browser.js",
"../encoding/utf8.js": "../encoding/utf8.browser.js",
"../src/cryptography/sha384.js": "../src/cryptography/sha384.browser.js",
"../src/cryptography/sha384.js":
"../src/cryptography/sha384.browser.js",
"../cryptography/sha384.js": "../cryptography/sha384.browser.js",
"./client/NodeIntegrationTestEnv.js": "./client/WebIntegrationTestEnv.js",
"../integration/client/NodeIntegrationTestEnv.js": "../integration/client/WebIntegrationTestEnv.js",
"./client/NodeIntegrationTestEnv.js":
"./client/WebIntegrationTestEnv.js",
"../integration/client/NodeIntegrationTestEnv.js":
"../integration/client/WebIntegrationTestEnv.js",
"../../src/client/NodeClient.js": "../../src/client/WebClient.js",
},
},
Expand Down

0 comments on commit d8e133e

Please sign in to comment.