简体   繁体   English

带ts-loader的NativeScript-Vue打字稿链式加载babel-loader

[英]NativeScript-Vue typescript chainloading babel-loader with ts-loader

I'm attempting to create a NativeScript-Vue project using TypeScript. 我正在尝试使用TypeScript创建NativeScript-Vue项目。 I have managed to get things building to a point where it is complaining about: 我设法使事情发展到了它抱怨的地步:

ERROR in app.ios.js from UglifyJs
Unexpected token: operator (>) [app.ios.js:132,15]

The offending line is: 令人反感的行是:

new __WEBPACK_IMPORTED_MODULE_0_nativescript_vue___default.a({
    // This line right here:
    render: h => h(__WEBPACK_IMPORTED_MODULE_1__components_Counter_vue__["a" /* default */]),
}).$start();

I may be naively assuming that I need to chain load babel-loader!ts-loader in my webpack.config.js but that just fails with: 我可能天真地假设我需要在webpack.config.js中链接加载babel-loader!ts-loader,但是失败了:

ERROR in Entry module not found: Error: Can't resolve 'babel-loader!ts-loader' in '/path/to/project'

The dependencies in my package.json are as follows: 我的package.json中的依赖项如下:

"dependencies": {
  "nativescript-theme-core": "^1.0.4",
  "nativescript-vue": "^1.3.1",
  "tns-core-modules": "~3.4.1",
  "typescript": "^2.8.3",
  "vuex": "^3.0.1"
},
"devDependencies": {
  "babel-core": "^6.26.0",
  "babel-loader": "^7.1.4",
  "babel-plugin-transform-object-rest-spread": "^6.26.0",
  "babel-preset-env": "^1.6.1",
  "copy-webpack-plugin": "^4.5.1",
  "css-loader": "^0.28.11",
  "extract-text-webpack-plugin": "^3.0.2",
  "fs-extra": "^5.0.0",
  "nativescript-vue-externals": "^0.2.0",
  "nativescript-vue-loader": "^0.1.5",
  "nativescript-vue-target": "^0.1.0",
  "nativescript-vue-template-compiler": "^1.3.1",
  "node-sass": "^4.7.2",
  "ns-vue-loader": "^0.1.2",
  "optimize-css-assets-webpack-plugin": "^3.2.0",
  "rimraf": "^2.6.2",
  "sass-loader": "^6.0.7",
  "ts-loader": "^3.5.0",
  "vue-template-compiler": "^2.5.16",
  "webpack": "^3.11.0",
  "webpack-synchronizable-shell-plugin": "0.0.7",
  "winston-color": "^1.0.0"
}

What am I doing wrong? 我究竟做错了什么? Am I looking at the problem incorrectly? 我看错了吗?

I resolved the issue by changing my webpack.config.js to have: 我通过将webpack.config.js更改为以下内容解决了该问题:

module: {
  rules: [
    {
      test: /\.js$/,
      exclude: /(node_modules)/,
      loader: 'babel-loader',
    },
    {
      test: /\.ts(x?)$/,
      exclude: /(node_modules)/,
      use: [
        {
          loader: 'babel-loader',
        },
        {
          loader: 'ts-loader',
          options: {
            appendTsSuffixTo: [/\.vue$/]
          },
        }
      ]
    },
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM