Skip to content

Commit

Permalink
UMD Vue build
Browse files Browse the repository at this point in the history
  • Loading branch information
barvian committed Dec 28, 2024
1 parent c28552b commit 2f9495d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/grumpy-actors-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@number-flow/vue': patch
---

Use UMD for CJS build (see #88)
9 changes: 5 additions & 4 deletions packages/vue/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "@number-flow/vue",
"type": "module",
"publishConfig": {
"access": "public"
},
Expand Down Expand Up @@ -32,14 +33,14 @@
"dist",
"README.md"
],
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"main": "./dist/index.umd.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
"import": "./dist/index.js",
"require": "./dist/index.umd.cjs"
}
},
"scripts": {
Expand Down
18 changes: 13 additions & 5 deletions packages/vue/vite.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,24 @@ export default defineConfig(({ mode }) => ({
build: {
outDir,
lib: {
entry: resolve(__dirname, 'src/index.ts'),
formats: ['es', 'cjs'],
fileName: 'index'
name: 'number-flow-vue', // required for UMD build
entry: {
index: resolve(__dirname, 'src/index.ts')
},
fileName: (format, name) => {
return `${name}.${format === 'es' ? 'js' : 'umd.cjs'}`
}
},
rollupOptions: {
external: ['vue', 'number-flow', 'esm-env'],
output: {
// Names for UMD builds
globals: {
vue: 'Vue'
}
vue: 'Vue',
'esm-env': 'Env',
'number-flow': 'NumberFlow'
},
exports: 'named'
}
}
}
Expand Down

0 comments on commit 2f9495d

Please sign in to comment.