尝试基于默认模板(使用TypeScript)在rollup
ASP.NET Core 2.0
应用程序上集成React
。
我正在尝试"rollup -c"
并显示此错误
[!]错误:node_modules \ punycode \ punycode.js不会导出'toASCII' https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module
node_modules \ rollup-plugin-node-builtins \ src \ es6 \ url.js(23:8)21:22:
23:从'punycode'导入 {toASCII} ;
24:从'util'导入{isObject,isString,isNullOrUndefined,isNull};
25:从'querystring'导入{解析为qsParse,stringify为qsStringify};
rollup.config.js
import typescript from 'rollup-plugin-typescript2';
import lessModules from 'rollup-plugin-less-modules';
import resolve from 'rollup-plugin-node-resolve';
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';
import builtins from 'rollup-plugin-node-builtins';
import globals from 'rollup-plugin-node-globals';
export default {
plugins: [
typescript(),
resolve(),
nodeResolve({
jsnext: true,
main: true,
browser: true
}),
commonjs({
include: [
'node_modules/**'
],
exclude: [
'node_modules/process-es6/**'
],
namedExports: {
'node_modules/react/react.js': ['Children', 'Component', 'PropTypes', 'createElement'],
'node_modules/react-dom/index.js': ['render']
}
}),
builtins(),
globals(),
json(),
lessModules({output: true})
],
input: './ClientApp/boot.tsx',
output: {
file: './wwwroot/dist/bundle.js',
format: 'iife'
},
external: [
'React',
'ReactDOM',
'reactRouterDom'
],
sourceMap: true
}
tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"module": "es2015",
"moduleResolution": "node",
"target": "es6",
"jsx": "react",
"sourceMap": true,
"skipDefaultLibCheck": true,
"strict": true
},
"exclude": [
"bin",
"node_modules"
]
}
的package.json
{
"name": "WebApplication",
"private": true,
"version": "0.0.0",
"devDependencies": {
"@types/history": "4.6.0",
"@types/react": "15.0.35",
"@types/react-dom": "15.5.1",
"@types/react-router": "4.0.12",
"@types/react-router-dom": "4.0.5",
"@types/rollup": "0.51.3",
"event-source-polyfill": "0.0.9",
"isomorphic-fetch": "2.2.1",
"react": "15.6.1",
"react-dom": "15.6.1",
"react-router-dom": "4.1.1",
"typescript": "2.4.1",
"rollup-plugin-typescript2": "0.9.0",
"rollup": "0.53.3",
"rollup-plugin-less-modules": "0.1.1",
"rollup-plugin-node-resolve": "3.0.0",
"rollup-plugin-commonjs": "8.2.6",
"rollup-plugin-json": "2.3.0",
"rollup-plugin-node-builtins": "2.1.2",
"rollup-plugin-node-globals": "1.1.0"
}
}
我尝试在punycode.js
中手动安装package.json
,但没有帮助。
答案 0 :(得分:0)
这有点像rollup-plugin-node-builtins的错误,这个问题看起来几乎和你的一样:https://github.com/calvinmetcalf/rollup-plugin-node-builtins/issues/38