Skip to content

Commit

Permalink
chore: 支持 cjs 和 mjs 形形式输出
Browse files Browse the repository at this point in the history
  • Loading branch information
luozefeng committed Nov 17, 2021
1 parent e8a2f57 commit ed2e1af
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
.DS_Store
.vscode
/dist
/es

# lock file
package-lock.json
Expand Down
3 changes: 2 additions & 1 deletion packages/lb-annotation/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ pnpm-lock.yaml

# build
/lib
/dist
/dist
/es
8 changes: 5 additions & 3 deletions packages/lb-annotation/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sensetime/annotation",
"version": "1.5.0-alpha.2",
"version": "1.5.0-alpha.3",
"description": "Annotation tool collection",
"keywords": [
"annotation",
Expand All @@ -18,9 +18,11 @@
},
"license": "Apache-2.0",
"files": [
"dist"
"dist",
"es"
],
"main": "./dist/index.js",
"module": "./es/index.js",
"types": "./dist/types/index.d.ts",
"author": "luozefeng",
"email": "luozefeng@sensetime.com",
Expand Down Expand Up @@ -92,4 +94,4 @@
"color-rgba": "^2.3.0",
"lodash": "^4.17.20"
}
}
}
7 changes: 6 additions & 1 deletion packages/lb-annotation/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,14 @@ export default {
],
output: [
{
format: 'es',
format: 'cjs',
file: './dist/index.js',
banner,
},
{
format: 'es',
file: './es/index.js',
banner,
},
],
};
1 change: 1 addition & 0 deletions packages/lb-components/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.DS_Store
.vscode
/dist
/es

# lock file
package-lock.json
Expand Down
12 changes: 7 additions & 5 deletions packages/lb-components/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
{
"name": "@sensetime/label-bee",
"version": "1.2.0-alpha.8",
"version": "1.2.0-alpha.9",
"description": "Provide a complete library of annotation components",
"main": "./dist/index.js",
"es": "./es/index.js",
"types": "./dist/types/index.d.ts",
"files": [
"dist",
"lib"
"lib",
"es"
],
"scripts": {
"dev": "npm run build && cross-env NODE_ENV=developemnt rollup -m -c rollup.config.js -w ",
"start": "npm run dev",
"dev:style": "node-sass src/index.scss dist/index.css -w",
"build:style": "node-sass src/index.scss dist/index.css && cp -R ./src/assets/cssIcon/. ./dist/assets/cssIcon",
"build:style": "node-sass src/index.scss dist/index.css && cp -R ./src/assets/cssIcon/. ./dist/assets/cssIcon && cp -R ./src/assets/cssIcon/. ./es/assets/cssIcon",
"build": "rm -fr dist && cross-env NODE_ENV=production rollup -c rollup.config.js && npm run build:style && npm run build:type",
"build:type": "tsc --emitDeclarationOnly",
"commit": "git-cz",
Expand Down Expand Up @@ -40,9 +42,9 @@
},
"dependencies": {
"@ant-design/icons": "^4.6.2",
"@sensetime/annotation": "1.5.0-alpha.2",
"@sensetime/annotation": "1.5.0-alpha.3",
"classnames": "^2.3.0",
"@sensetime/lb-utils": "^1.0.0",
"@sensetime/lb-utils": "^1.0.1",
"lodash": "^4.17.21",
"react-i18next": "^11.12.0",
"react-redux": "^7.2.3",
Expand Down
11 changes: 9 additions & 2 deletions packages/lb-components/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,22 @@ const customResolver = resolve({

const projectRootDir = path.resolve(__dirname);

const OUTPUT_DIR = 'dist';
const CJS_OUTPUT_DIR = 'dist';
const ES_OUTPUT_DIR = 'es';
const isProd = process.env.NODE_ENV === 'production';

export default {
input: 'src/index.tsx',
output: [
{
format: 'es',
dir: OUTPUT_DIR,
dir: ES_OUTPUT_DIR,
preserveModules: true,
preserveModulesRoot: 'src',
},
{
format: 'cjs',
dir: CJS_OUTPUT_DIR,
preserveModules: true,
preserveModulesRoot: 'src',
},
Expand Down
4 changes: 2 additions & 2 deletions packages/lb-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"version": "1.1.0",
"private": true,
"dependencies": {
"@sensetime/label-bee": "^1.2.0-alpha.8",
"@sensetime/label-bee": "^1.2.0-alpha.9",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@sensetime/lb-utils": "^1.0.0",
"@sensetime/lb-utils": "^1.0.1",
"qs": "^6.10.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand Down
3 changes: 3 additions & 0 deletions packages/lb-utils/lib/index-module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import i18n from "./i18n";

export { i18n };
18 changes: 16 additions & 2 deletions packages/lb-utils/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
import i18n from "./i18n";
const i18n = require("i18next");
const { initReactI18next } = require("react-i18next");
const resources = require("./i18n/resources.json");

export { i18n };
i18n
.use(initReactI18next) // passes i18n down to react-i18next
.init({
resources,
lng: "cn",
interpolation: {
escapeValue: false,
},
});

module.exports = {
i18n,
};
6 changes: 4 additions & 2 deletions packages/lb-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{
"name": "@sensetime/lb-utils",
"version": "1.0.0",
"version": "1.0.1",
"description": "utils for label-bee",
"author": "lijingchi <lijingchi1@sensetime.com>",
"types": "./lib/index.d.ts",
"homepage": "",
"license": "ISC",
"main": "lib/index.js",
"module": "lib/index-module.js",
"files": [
"lib"
"lib",
"es"
],
"repository": {
"type": "git",
Expand Down

0 comments on commit ed2e1af

Please sign in to comment.