@snack-kit/scripts 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/config/webpack.shared.js +4 -1
- package/package.json +3 -1
- package/template/dev/index.tsx +3 -4
- package/template/entry/index.tsx +2 -3
- package/template/snack/index.tsx +2 -3
package/README.md
CHANGED
|
@@ -142,6 +142,12 @@ module.exports = (config) => {
|
|
|
142
142
|
|
|
143
143
|
## Changelog
|
|
144
144
|
|
|
145
|
+
### 0.2.0
|
|
146
|
+
|
|
147
|
+
- 新增:`MIGRATION.md` 迁移指南,说明从 `@para-snack/*` / `@paraview/*` 迁移到 `@snack-kit/*` 的完整步骤
|
|
148
|
+
- 新增:`config/webpack.shared.js` 共享 webpack 配置模块
|
|
149
|
+
- 重构:`template/dev/index.tsx`、`template/entry/index.tsx`、`template/snack/index.tsx` 模板文件更新,适配新包名
|
|
150
|
+
|
|
145
151
|
### 0.1.0
|
|
146
152
|
|
|
147
153
|
- 新增:`snack-scripts init [dir]` 命令,交互式初始化新 snack 工程
|
package/config/webpack.shared.js
CHANGED
|
@@ -25,7 +25,10 @@ function createResolve(extraAlias = {}) {
|
|
|
25
25
|
assets: path.join(process.env.PROJECT_PATH, 'src/assets'),
|
|
26
26
|
// @snack-kit/core 的 package.json module 字段路径有误,直接指向 cjs
|
|
27
27
|
'@snack-kit/core': path.resolve(__dirname, '../node_modules/@snack-kit/core/dist/cjs/index.js'),
|
|
28
|
-
|
|
28
|
+
// 强制 dev 模板使用 snack-scripts 自身的 react,避免项目中旧版 react 被命中
|
|
29
|
+
'react': path.resolve(__dirname, '../node_modules/react'),
|
|
30
|
+
'react-dom': path.resolve(__dirname, '../node_modules/react-dom'),
|
|
31
|
+
...extraAlias
|
|
29
32
|
}
|
|
30
33
|
};
|
|
31
34
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snack-kit/scripts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "snack-cli package scripts Powered by Para FED",
|
|
5
5
|
"bin": {
|
|
6
6
|
"snack-scripts": "./bin/main.js"
|
|
@@ -33,6 +33,8 @@
|
|
|
33
33
|
"@babel/preset-react": "^7.24.7",
|
|
34
34
|
"@babel/preset-typescript": "^7.24.7",
|
|
35
35
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.3",
|
|
36
|
+
"react": "^19.0.0",
|
|
37
|
+
"react-dom": "^19.0.0",
|
|
36
38
|
"@snack-kit/core": "file:../core",
|
|
37
39
|
"@snack-kit/lib": "^0.6.0",
|
|
38
40
|
"@swc/core": "^1.2.100",
|
package/template/dev/index.tsx
CHANGED
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import ReactDOM from 'react-dom';
|
|
5
|
-
import {createRoot} from 'react-dom/client';
|
|
6
5
|
import {Context, Debugger} from '@snack-kit/lib';
|
|
7
6
|
import App from './App';
|
|
8
7
|
|
|
9
8
|
/** import snack modules **/
|
|
10
9
|
|
|
11
|
-
import {SnackSDK} from '@snack-kit/core';
|
|
10
|
+
import {SnackSDK, createReactRoot} from '@snack-kit/core';
|
|
12
11
|
|
|
13
12
|
import 'template/normalize.scss';
|
|
14
13
|
import './index.scss';
|
|
@@ -24,7 +23,7 @@ const packages = JSON.parse(`/** vers packages **/`);
|
|
|
24
23
|
|
|
25
24
|
|
|
26
25
|
async function init() {
|
|
27
|
-
await Debugger.init(projectPkg.dev.debug || []);
|
|
26
|
+
await Debugger.init({gateways: projectPkg.dev.debug || []});
|
|
28
27
|
const sdk = new SnackSDK({
|
|
29
28
|
service: Context.get('snackbar'),
|
|
30
29
|
importMaps: {
|
|
@@ -58,7 +57,7 @@ async function init() {
|
|
|
58
57
|
/>
|
|
59
58
|
);
|
|
60
59
|
};
|
|
61
|
-
const root =
|
|
60
|
+
const root = createReactRoot(document.getElementById('app')!);
|
|
62
61
|
root.render(<Main/>);
|
|
63
62
|
|
|
64
63
|
}
|
package/template/entry/index.tsx
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import ReactDOM from 'react-dom';
|
|
4
|
-
import {createRoot} from 'react-dom/client';
|
|
5
4
|
import {Context, GetURLParams} from '@snack-kit/lib';
|
|
6
5
|
import * as SnackLib from '@snack-kit/lib';
|
|
7
6
|
|
|
8
|
-
import {SnackSDK} from '@snack-kit/core';
|
|
7
|
+
import {SnackSDK, createReactRoot} from '@snack-kit/core';
|
|
9
8
|
import '../normalize.scss';
|
|
10
9
|
|
|
11
10
|
/** import plugin js **/
|
|
@@ -44,7 +43,7 @@ import '../normalize.scss';
|
|
|
44
43
|
});
|
|
45
44
|
window.snackSDK = sdk;
|
|
46
45
|
const Page = await sdk.createPageComponent({id, type});
|
|
47
|
-
const root =
|
|
46
|
+
const root = createReactRoot(document.getElementById('app'));
|
|
48
47
|
root.render((
|
|
49
48
|
<Page/>
|
|
50
49
|
));
|
package/template/snack/index.tsx
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import ReactDOM from 'react-dom';
|
|
4
|
-
import {createRoot} from 'react-dom/client';
|
|
5
4
|
import {Context, Origin, axios} from '@snack-kit/lib';
|
|
6
5
|
|
|
7
|
-
import {SnackSDK} from '@snack-kit/core';
|
|
6
|
+
import {SnackSDK, createReactRoot} from '@snack-kit/core';
|
|
8
7
|
import '../normalize.scss';
|
|
9
8
|
|
|
10
9
|
/** import plugin js **/
|
|
@@ -28,7 +27,7 @@ async function init() {
|
|
|
28
27
|
let StttingMain;
|
|
29
28
|
if (Setting)
|
|
30
29
|
StttingMain = await sdk.createModuleComponent({main, name: SnackName, type: SnackType, setting: true});
|
|
31
|
-
const root =
|
|
30
|
+
const root = createReactRoot(document.getElementById('app')!);
|
|
32
31
|
root.render((
|
|
33
32
|
<>
|
|
34
33
|
{StttingMain ? (
|