Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] umi max由4.1.2升级至4.1.5版本出现的打包问题 #12236

Closed
snail-climb opened this issue Mar 26, 2024 · 2 comments
Closed

[Bug] umi max由4.1.2升级至4.1.5版本出现的打包问题 #12236

snail-climb opened this issue Mar 26, 2024 · 2 comments

Comments

@snail-climb
Copy link

snail-climb commented Mar 26, 2024

What happens?

我把umi max由4.1.2升级至4.1.5版本,我发现打包后的index.html里多了一行script,内容如下:

<script>!function(){"use strict";var t="/".replace(/([^/])$/,"$1/"),e=location.pathname,n=e.startsWith(t)&&decodeURI("/".concat(e.slice(t.length)));if(n){var a=document,c=a.head,r=a.createElement.bind(a),i=function(t,e,n){var a,c=e.r[t]||(null===(a=Object.entries(e.r).find((function(e){var n=e[0];return new RegExp("^".concat(n.replace(/\/:[^/]+/g,"/[^/]+").replace("/*","/.+"),"$")).test(t)})))||void 0===a?void 0:a[1]);return null==c?void 0:c.map((function(t){var a=e.f[t][1],c=e.f[t][0];return{type:c.split(".").pop(),url:"".concat(n.publicPath).concat(c),attrs:[["data-".concat(e.b),"".concat(e.p,":").concat(a)]]}}))}(n,{"p":"web","b":"webpack","f":[["189.a7beabfa.async.js",189],["378.e5dde627.async.js",378],["455.1bde7e3e.async.js",455],["948.59d43568.async.js",948],["1056.f9487777.async.js",1056],["2474.87195e87.async.js",2474],["p__404.da4b8aba.async.js",2571],["2701.b37e874d.async.js",2701],["p__Business__Salary__index.5810c60c.async.js",3090],["3093.0cbf86ad.async.js",3093],["3157.d2bcff5b.async.js",3157],["p__Home__index.6a94e0f9.async.js",3371],["3771.51115d5f.async.js",3771],["4285.56a1d016.async.js",4285],["4318.48297ad4.async.js",4318],["4574.6a948d5c.async.js",4574],["p__Business__Handwriting__index.d6bfd92b.async.js",5577],["6228.2d538008.async.js",6228],["6276.8d68bb29.async.js",6276],["t__plugin-layout__Layout.6cae69f5.chunk.css",6301],["t__plugin-layout__Layout.000bc505.async.js",6301],["p__Login__index.9d4004e4.async.js",6739],["p__Monitor__DruidMonitor__index.4698b5b4.chunk.css",7458],["p__Monitor__DruidMonitor__index.9badaea8.async.js",7458],["8474.657f4167.async.js",8474],["p__Business__Doraemon__index.8c2ad141.chunk.css",8770],["p__Business__Doraemon__index.aa5ee09e.async.js",8770],["9117.a00802a9.async.js",9117],["p__Map__index.7b2a61de.chunk.css",9479],["p__Map__index.d8faf829.async.js",9479],["9696.5c13c2c5.async.js",9696]],"r":{"/*":[3,6,4,9,18,19,20],"/":[3,4,9,18,19,20],"/login":[2,5,7,12,18,21,27],"/home":[4,11,12,15,18,3,9,19,20],"/map":[5,7,10,24,28,29,3,4,9,18,19,20],"/business/handwriting":[2,3,4,5,7,12,13,15,16,18,27,30,9,19,20],"/business/doraemon":[1,2,4,7,10,13,14,18,25,26,3,9,19,20],"/business/salary":[0,4,8,12,14,15,18,3,9,19,20],"/monitor/druid":[22,23,3,4,9,18,19,20],"/parent/child2":[4,11,12,15,18,3,9,19,20],"/parent/child1/subChild1":[4,11,12,15,18,3,9,19,20],"/parent/child1/subChild2":[4,11,12,15,18,3,9,19,20]}},{publicPath:"/"});null==i||i.forEach((function(t){var e,n=t.type,a=t.url;if("js"===n)(e=r("script")).src=a,e.async=!0;else{if("css"!==n)return;(e=r("link")).href=a,e.rel="preload",e.as="style"}t.attrs.forEach((function(t){e.setAttribute(t[0],t[1]||"")})),c.appendChild(e)}))}}();</script>

我期望打包不输出这个script,请问如何配置关闭呢,在umi max 4.1.2版本打包时没有这个内容的。

Mini Showcase Repository(REQUIRED)

Please provide a minimal reproduction then upload to your GitHub. 请提供 最小重现,并上传到你的 GitHub 仓库
这个问题比较简单,一定是4.1.2之后的升级对打包做了改变造成的,现在期望不输出这个script了,因为我的前端是要打包到后端,用后端访问的,如果有这段脚本会访问报错。

How To Reproduce

Steps to reproduce the behavior: 1. 2.

Expected behavior 1. 2.

Context

  • Umi Max Version:4.1.5
  • Node Version:18
Copy link

由于缺乏足够的信息,我们暂时关闭了该 Issue。请修改(不要回复) Issue 提供最小重现以重新开启。谢谢。

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 26, 2024
@fz6m
Copy link
Contributor

fz6m commented Mar 27, 2024

这一段逻辑是从 4.1.5 开始默认都会有的,目前不可以关闭。目的是为了预加载子包,从而在打开其他路由页面时展示的速度更快,体验更好。

如果你在微前端子应用里遇到了加载失败的问题,这个是一个已知问题,在 #12230 跟进,预计下个版本修复。

如果不是这个问题,可以提供一个遇到问题的最小复现。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants