web: Add config to support npm module

This commit is contained in:
Jinny You 2023-12-15 16:45:30 +09:00 committed by Hermet Park
parent e3f3a97f8d
commit b8d64c5ecd
3 changed files with 25 additions and 8 deletions

View file

@ -2,7 +2,21 @@
"name": "@thorvg/lottie-player", "name": "@thorvg/lottie-player",
"version": "1.0.0-beta.0", "version": "1.0.0-beta.0",
"description": "A web lottie player using ThorVG as a renderer", "description": "A web lottie player using ThorVG as a renderer",
"main": "index.js", "main": "./dist/lottie-player.cjs.js",
"module": "./dist/lottie-player.esm.js",
"exports": {
".": {
"import": "./dist/lottie-player.cjs.js",
"require": "./dist/lottie-player.esm.js"
}
},
"publishConfig": {
"access": "public"
},
"files": [
"dist/"
],
"types": "./dist/lottie-player.d.ts",
"scripts": { "scripts": {
"build": "npm run clean && npm run copy:wasm && THORVG_VERSION=$(sed -n -e 4p ../meson.build | sed 's/..$//' | sed -r 's/.{19}//') rollup -c --bundleConfigAsCjs && rm -rf ./dist/thorvg-wasm.js", "build": "npm run clean && npm run copy:wasm && THORVG_VERSION=$(sed -n -e 4p ../meson.build | sed 's/..$//' | sed -r 's/.{19}//') rollup -c --bundleConfigAsCjs && rm -rf ./dist/thorvg-wasm.js",
"build:watch": "npm run clean && npm run copy:wasm && rollup -c --bundleConfigAsCjs --watch", "build:watch": "npm run clean && npm run copy:wasm && rollup -c --bundleConfigAsCjs --watch",
@ -44,9 +58,11 @@
"rollup-plugin-dts": "^6.1.0", "rollup-plugin-dts": "^6.1.0",
"rollup-plugin-polyfill-node": "^0.13.0", "rollup-plugin-polyfill-node": "^0.13.0",
"rollup-plugin-swc3": "^0.10.4", "rollup-plugin-swc3": "^0.10.4",
"rollup-plugin-terser": "^7.0.2",
"typescript": "*" "typescript": "*"
}, },
"dependencies": { "dependencies": {
"lit": "^3.1.0" "lit": "^3.1.0",
"url": "^0.11.3"
} }
} }

View file

@ -7,10 +7,11 @@ import nodePolyfills from 'rollup-plugin-polyfill-node';
import bakedEnv from 'rollup-plugin-baked-env'; import bakedEnv from 'rollup-plugin-baked-env';
import pkg from './package.json'; import pkg from './package.json';
const extensions = [".js", ".jsx", ".ts", ".tsx", ".mjs", ".wasm"]; const name = 'lottie-player';
const globals = { const globals = {
'lit': 'lit', url: "url",
'lit/decorators.js': 'lit/decorators.js', lit: "lit",
"lit/decorators.js": "lit/decorators.js",
}; };
export default [ export default [

View file

@ -32,11 +32,11 @@
"skipLibCheck": true "skipLibCheck": true
}, },
"include": [ "include": [
"src/**/*.ts", "src/**/*.ts"
"types/**/*.ts"
], ],
"exclude": [ "exclude": [
"node_modules", "node_modules",
"dist", "example",
"dist"
], ],
} }