Skip to content

Commit

Permalink
chore: bundle by tsup
Browse files Browse the repository at this point in the history
  • Loading branch information
geekact committed May 6, 2022
1 parent fc78c6a commit 7239398
Show file tree
Hide file tree
Showing 9 changed files with 909 additions and 368 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/ci.yml → .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
name: CI
name: Pre Release

on:
push:
branches:
pull_request:
branches:
release:
types: [prereleased]

jobs:
publish:
if: "!contains(toJson(github.event.commits), '[skip ci]')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: 14
- run: yarn install
- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
tag: next
20 changes: 20 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Release

on:
release:
types: [released]

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
- run: yarn install
- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
tag: latest
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ node_modules/
coverage
.nyc_output
TODO
test.js
test.ts
/es/
/lib/
/types/
/test.*
/dist/
/build/
56 changes: 34 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,32 @@
"name": "foca-taro-storage",
"version": "0.1.2",
"repository": "[email protected]:foca-js/foca-taro-storage.git",
"author": "geekact",
"keywords": [
"taro-persist",
"taro-storage"
],
"description": "Foca持久化taro引擎",
"contributors": [
"罪 <[email protected]> (https://github.com/geekact)"
],
"license": "MIT",
"main": "lib/index.js",
"module": "es/index.js",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"scripts": {
"prepublishOnly": "ts-prepublish",
"prepublishOnly": "tsup",
"prepare": "husky install"
},
"exports": {
".": {
"require": "./lib/index.js",
"import": "./es/index.js"
},
"./": "./"
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
}
},
"files": [
"lib",
"es",
"dist",
"src",
"LICENSE",
"package.json",
"README.md",
Expand All @@ -31,20 +39,24 @@
]
},
"peerDependencies": {
"foca": "^0.9.0",
"taro": "^3.0.0"
},
"devDependencies": {
"@commitlint/cli": "^16.0.1",
"@commitlint/config-conventional": "^16.0.0",
"@tarojs/taro": "^3.3.19",
"@types/node": "^17.0.8",
"foca": "^0.9.2",
"husky": "^7.0.4",
"ts-prepublish": "^2.0.0",
"typescript": "^4.5.4"
"@tarojs/taro": "^3.0.0",
"foca": ">=0.11.0",
"react": ">=16.9.0"
},
"dependencies": {
"hoist-non-react-statics": "^3.3.2"
},
"devDependencies": {
"@commitlint/cli": "^16.2.4",
"@commitlint/config-conventional": "^16.2.4",
"@swc/core": "^1.2.177",
"@tarojs/taro": "^3.4.8",
"@types/node": "^17.0.31",
"foca": "^0.11.1",
"husky": "^7.0.4",
"prettier": "^2.6.2",
"react": "^18.1.0",
"tsup": "^5.12.7",
"typescript": "^4.6.4"
}
}
9 changes: 5 additions & 4 deletions src/hoc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import React, { ComponentType, useEffect, useState, FC } from 'react';
// 路由入口没有ref的需求,所以不需要增加forwardRef
export function persistInterceptor<T>(EntryComponent: ComponentType<T>) {
const HOC: FC<T> = (props) => {
const [ready, setReady] = useState(false);
const [ready, setReady] = useState(store.isReady);

useEffect(() => {
store.onInitialized().then(() => {
setReady(true);
});
ready ||
store.onInitialized().then(() => {
setReady(true);
});
}, []);

return ready ? <EntryComponent {...props} /> : null;
Expand Down
7 changes: 0 additions & 7 deletions tsconfig.cjs.json

This file was deleted.

3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping
"target": "ES2015",
"module": "ES2015",
"lib": ["ESNext", "DOM"],
"lib": ["ESNext"],
"allowJs": false,
"declaration": true,
"outDir": "./build",
Expand All @@ -29,7 +29,6 @@
"moduleResolution": "node",
"esModuleInterop": true,
"resolveJsonModule": true,
"typeRoots": ["node_modules/@types", "./typings"],

"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
Expand Down
14 changes: 14 additions & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineConfig } from 'tsup';

export default defineConfig({
entry: ['src/index.ts'],
splitting: true,
sourcemap: true,
clean: true,
format: ['cjs', 'esm'],
platform: 'node',
tsconfig: './tsconfig.json',
target: 'es5',
shims: false,
dts: true,
});
Loading

0 comments on commit 7239398

Please sign in to comment.