Skip to content

Commit

Permalink
feat: bump devtool
Browse files Browse the repository at this point in the history
  • Loading branch information
fantasticsoul committed Mar 16, 2024
1 parent 6c07650 commit b98ce96
Show file tree
Hide file tree
Showing 4 changed files with 3,488 additions and 3,361 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"scripts": {
"build": "turbo run build",
"build:watch": "turbo run build:watch",
"build_devtool": "pnpm --filter=helux-devtool run build",
"build_devtool": "pnpm --filter=@helux/plugin-devtool run build",
"build_helux": "pnpm --filter=helux run build",
"changeset": "changeset",
"commitlint": "commitlint -e $HUSKY_GIT_PARAMS",
Expand Down
10 changes: 6 additions & 4 deletions packages/helux-plugin-devtool/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@helux/plugin-devtool",
"version": "4.0.1",
"version": "4.0.3",
"description": "devtool for helux",
"bugs": {
"url": "https://github.com/heluxjs/helux/issues"
Expand Down Expand Up @@ -31,15 +31,17 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"helux": "workspace:^",
"helux": "^4.2.0",
"redux": "^4.2.1"
},
"peerDependencies": {},
"bundleDependencies": false,
"publishConfig": {
"access": "public",
"main": "dist/index.js",
"registry": "https://registry.npmjs.org/"
},
"deprecated": false
"deprecated": false,
"devDependencies": {
"terser": "^5.29.1"
}
}
9 changes: 7 additions & 2 deletions packages/helux-plugin-devtool/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ const moduleInfoMap: Record<string, { name: string; state: any }> = {
[pluginName]: { name: pluginName, state: 'init helux devtool' }, // 避免调试时再刷新浏览器出现 no store 错误导致 devtool 无法启动
};

function getWindow() {
// @ts-ignore
return window || global;
}

function createReducer(module: string, initState = {}) {
return function (state: any, action: any) {
if (state === undefined) state = initState;
Expand All @@ -34,10 +39,10 @@ function tryInjectReduxDevTool() {
const redecers = createReducers();
if (!Object.keys(redecers).length) return;

const g = getWindow(); // global this
reduxStore = createStore(
combineReducers(redecers),
// @ts-ignore
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__(),
g.__REDUX_DEVTOOLS_EXTENSION__ && g.__REDUX_DEVTOOLS_EXTENSION__(),
);
injected = true;

Expand Down
Loading

0 comments on commit b98ce96

Please sign in to comment.