我有一个正在构建的NextJS网站,它很棒,但是它不能在IE 10/11中正常工作,因为某些代码没有正确地转译。我对babel和webpack真的很不好,以前从来没有自己配置过它们。我一直在尝试通过在线阅读来解决两天,似乎没有任何工作适合我。
我得到的确切错误是weakSet is not defined
,它来自common.js文件。
这是我的.babelrc文件,位于项目的根目录中。
// .babelrc
{
"presets": ["next/babel"],
"plugins": [
["styled-components", {
"ssr": true,
"displayName": true,
"preprocess": false
}]
]
}
我的package.json
{
"name": "bradshouse",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "next",
"build": "next build",
"start": "next start"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"next": "^7.0.2",
"react": "^16.6.0",
"react-dom": "^16.6.0",
"react-pose": "^4.0.1",
"styled-components": "^4.0.2"
},
"devDependencies": {
"babel-plugin-styled-components": "^1.8.0"
}
}
如果您有兴趣自己启动完整的repo,请点击这里。节点模块被排除在外,因此npm install,然后npm run build,然后npm run start。
https://github.com/TJBlackman/Brads-House
谢谢您的帮助!随意链接文章,我将彻底阅读它们!谢谢。
Edit: As a quick fix, I added this polyfill script to the <head>
of all my pages, and it still did not fix this issue... Wat?! <script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script>