Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加播放器 SDK 对 ESM 规范的支持 #380

Open
wants to merge 3 commits into
base: v3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ node_modules
.cache
.parcel-cache
demo/.vitepress/dist
yarn.lock
package-lock.json
.DS_Store
25 changes: 24 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
{
"name": "jessibuca",
"version": "1.0.0",
"main": "dist/jessibuca.js",
"module": "dist/jessibuca.esm.js",
"unpkg": "dist/jessibuca.js",
"jsdelivr": "dist/jessibuca.js",
"types": "dist/jessibuca.d.ts",
"files": [
"dist",
"package.json",
"LICENSE",
"README.md",
"README.en.md"
],
"exports": {
".": {
"import": {
"types": "./dist/jessibuca.d.ts",
"default": "./dist/jessibuca.esm.js"
},
"require": {
"types": "./dist/jessibuca.d.ts",
"default": "./dist/jessibuca.js"
}
}
},
"scripts": {
"build": "npx cross-env NODE_ENV=production rollup -c",
"build:wasm": "python wasm/make.py --wasm && npm run build && npm run build:demo",
Expand Down Expand Up @@ -41,7 +65,6 @@
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-string": "^3.0.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-worker-inline": "^1.0.6",
"rollup-plugin-copy": "^3.4.0",
"servor": "^4.0.2"
},
Expand Down
25 changes: 16 additions & 9 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import json from '@rollup/plugin-json'; // 解析json格式
import copy from 'rollup-plugin-copy'; // 直接复制文件和文件夹。
import {terser} from 'rollup-plugin-terser'; // 压缩
import base64 from 'postcss-base64'; // 图片变成base64
import packageJson from './package.json';


const isProd = process.env.NODE_ENV === 'production';

const baseConfig = {
output: {
format: 'umd',
sourcemap: !isProd,
},
plugins: [
Expand Down Expand Up @@ -72,10 +72,19 @@ const baseConfig = {
export default [
{
input: 'src/jessibuca.js',
output: {
name: 'jessibuca',
file: isProd ? 'dist/jessibuca.js' : 'demo/public/jessibuca.js',
},
output: [
{
name: 'jessibuca',
file: isProd ? packageJson.main : 'demo/public/jessibuca.js',
format: 'umd',
...baseConfig.output
},
{
file: isProd ? packageJson.module : 'demo/public/jessibuca.js',
format: 'esm',
...baseConfig.output
}
],
plugins: [
postcss({
plugins: [
Expand All @@ -99,16 +108,14 @@ export default [
output: {
name: 'decoder',
file: isProd ? 'dist/decoder.js' : 'demo/public/decoder.js',
...baseConfig.output
},
plugins: [],
}
].map(config => {
return {
input: config.input,
output: {
...baseConfig.output,
...config.output,
},
output: config.output,
plugins: [...baseConfig.plugins, ...config.plugins],
};
});