rollup打包ts报错:Original error: Cannot use import statement outside a module

package.jsonscripts 对应的命令行后面,加上 --bundleConfigAsCjs,如:

"scripts": {
  "test": "echo \"Error: no test specified\" && exit 1",
  "dev": "rollup -c -w --bundleConfigAsCjs",
  "build": "rollup -c --bundleConfigAsCjs"
},

再次打包即可

你可能感兴趣的:(Typescript,typescript,rollup)