Skip to content

Commit

Permalink
Merge pull request #35 from mayinrain/master
Browse files Browse the repository at this point in the history
add script to build esm-browser
  • Loading branch information
nancyzhan authored Apr 1, 2024
2 parents 68ce481 + 8d4b661 commit 47efd50
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fesjs/traction-widget",
"version": "1.8.10",
"version": "1.8.11",
"description": "集合大型中台项目使用到的通用组件和工具函数",
"scripts": {
"docs:dev": "npm run build && vitepress dev docs",
Expand All @@ -9,13 +9,14 @@
"prepare": "husky install",
"commit": "git-cz",
"build:esm": "node scripts/build-esm.js",
"build:esm-browser": "node scripts/build-browser.mjs",
"build:umd": "node scripts/build-umd.js",
"build:type": "node scripts/build-types.js",
"build:style": "node scripts/build-style.js",
"build.unix": "rm -rf packages/traction-widget/dist packages/traction-widget/es && npm run build:esm && npm run build:type && npm run build:style && npm run build:umd",
"build.unix": "rm -rf packages/traction-widget/dist packages/traction-widget/es && npm run build:esm && npm run build:type && npm run build:style && npm run build:umd && npm run build:esm-browser",
"release": "npm run build && node scripts/release.js",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"build.win": "npm run build:esm && npm run build:type && npm run build:style && npm run build:umd",
"build.win": "npm run build:esm && npm run build:type && npm run build:style && npm run build:umd && npm run build:esm-browser",
"build": "node scripts/build.js"
},
"files": [
Expand Down
18 changes: 18 additions & 0 deletions scripts/build-browser.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import path from 'path';
import fse from 'fs-extra';
import { rollup } from 'rollup';

import { getRollupConfig, OUTPUT_DIR } from './build-shard.js';

fse.mkdirsSync(OUTPUT_DIR);

async function compiler() {
const bundle = await rollup(getRollupConfig());
const outputFilePath = path.join(OUTPUT_DIR, 'traction-widget.esm-browser.js');
await bundle.write({
file: outputFilePath,
format: 'esm',
});
}

compiler();

0 comments on commit 47efd50

Please sign in to comment.