@lark-apaas/fullstack-rspack-preset 1.0.26-alpha.3 → 1.0.26-alpha.5

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.
@@ -71,16 +71,11 @@ class SlardarPerformanceMonitorPlugin {
71
71
  tag.attributes.src.includes('main.js'));
72
72
  if (mainJsIndex !== -1) {
73
73
  // 在 main.js 之前插入 Slardar 脚本
74
- data.headTags = [
75
- ...data.headTags.slice(0, mainJsIndex),
76
- ...slardarTags,
77
- ...data.headTags.slice(mainJsIndex),
78
- ];
74
+ data.headTags.splice(mainJsIndex, 0, ...slardarTags, teaTag);
79
75
  }
80
76
  else {
81
77
  // 如果没找到 main.js,插入到 headTags 最前面
82
- data.headTags = slardarTags.concat(data.headTags);
83
- data.headTags.unshift(teaTag);
78
+ data.headTags.unshift(...slardarTags, teaTag);
84
79
  }
85
80
  return data;
86
81
  });
@@ -96,19 +91,14 @@ function getSlardarScriptContent(option = {}) {
96
91
  const bid = option.bid || 'apaas_ai';
97
92
  const globalName = option.globalName || 'KSlardarWeb';
98
93
  return [
99
- {
100
- tagName: 'script',
101
- voidTag: false,
102
- attributes: {
103
- src: `https://lf3-short.ibytedapm.com/slardar/fe/sdk-web/browser.cn.js?bid=${bid}&globalName=${globalName}`,
104
- crossOrigin: 'anonymous',
105
- defer: true,
106
- },
107
- },
108
94
  {
109
95
  tagName: 'script',
110
96
  voidTag: false,
111
97
  innerHTML: `
98
+ const slardarScript = document.createElement('script');
99
+ slardarScript.src = 'https://lf3-short.ibytedapm.com/slardar/fe/sdk-web/browser.cn.js?bid=${bid}&globalName=${globalName}';
100
+ slardarScript.crossOrigin = 'anonymous';
101
+
112
102
  // 添加 onload 事件处理
113
103
  slardarScript.onload = function() {
114
104
  // 脚本加载完成后执行初始化
@@ -126,6 +116,9 @@ function getSlardarScriptContent(option = {}) {
126
116
  slardarScript.onerror = function() {
127
117
  console.warn('Failed to load Slardar script');
128
118
  };
119
+
120
+ // 将脚本添加到页面
121
+ document.head.appendChild(slardarScript);
129
122
  `,
130
123
  attributes: {},
131
124
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-rspack-preset",
3
- "version": "1.0.26-alpha.3",
3
+ "version": "1.0.26-alpha.5",
4
4
  "files": [
5
5
  "lib",
6
6
  "patches",
@@ -35,7 +35,7 @@
35
35
  "@lark-apaas/miaoda-inspector-babel-plugin": "^1.0.0",
36
36
  "@lark-apaas/miaoda-inspector-jsx-runtime": "^1.0.0",
37
37
  "@rspack/plugin-react-refresh": "^1.5.1",
38
- "@swc/plugin-styled-jsx": "^11.0.0",
38
+ "@swc/plugin-styled-jsx": "11.0.0",
39
39
  "clsx": "^2.1.1",
40
40
  "colorjs.io": "^0.5.2",
41
41
  "dotenv": "^16.4.5",