用于生产的Aurelia构建会创建具有“未定义”内容的捆绑包

时间:2017-08-17 11:00:00

标签: aurelia aurelia-cli

您好我有一个通过Aurelia CLI构建的Web应用程序。为了解决性能问题(我解决了here),我更新了最新版本的Aurelia(0.30.1,修复了性能问题)。为此,我必须更新其他npm软件包,首先使用npm-check-updates软件包将semver强制为最新版本

npm install -g npm-check-updates
ncu --upgrade
npm update
npm install babel-runtime --save-dev
npm install timers-ext --save-dev
npm install gulp-sourcemaps --save-dev
npm install aurelia-pal --save-dev
npm install aurelia-binding --save-dev
npm install aurelia-templating --save-dev

这是我的aurelia.json文件

{
 "name": "XX.YY.Web",
  "type": "project:application",
  "platform": {
    "id": "web",
    "displayName": "Web",
    "output": "scripts",
    "index": "index.html"
  },
  "transpiler": {
    "id": "babel",
    "displayName": "Babel",
    "fileExtension": ".js",
    "options": {
      "plugins": [
        "transform-es2015-modules-amd"
      ]
    },
    "source": "src\\**\\*.js"
  },
  "markupProcessor": {
    "id": "none",
    "displayName": "None",
    "fileExtension": ".html",
    "source": "src\\**\\*.html"
  },
  "cssProcessor": {
    "id": "none",
    "displayName": "None",
    "fileExtension": ".css",
    "source": "src\\**\\*.css"
  },
  "editor": {
    "id": "vscode",
    "displayName": "Visual Studio Code"
  },
  "unitTestRunner": {
    "id": "karma",
    "displayName": "Karma",
    "source": "test\\unit\\**\\*.js"
  },
  "paths": {
    "root": "src"
  },
  "testFramework": {
    "id": "jasmine",
    "displayName": "Jasmine"
  },
  "build": {
    "targets": [
      {
        "id": "web",
        "displayName": "Web",
        "output": "scripts",
        "index": "scripts/index.html",
        "useAbsolutePath": true
      }
    ],
    "loader": {
      "type": "require",
      "configTarget": "vendor-bundle.js",
      "includeBundleMetadataInConfig": "auto",
      "config": {
        "waitSeconds": 0,
        "paths": {
          "jquery": "../scripts/lib/cdn/jquery-3.1.0.min",
          "breeze-client":  "../node_modules/breeze-client/breeze.debug"
        }
      },
      "plugins": [
        {
          "name": "text",
          "extensions": [
            ".html",
            ".css"
          ],
          "stub": true
        }
      ]
    },
    "options": {
      "minify": "stage & prod",
      "sourcemaps": "dev & stage",
      "rev": "stage & prod"
    },
    "bundles": [
      {
        "name": "app-bundle.js",        
        "source": [
          "[**/*.js]",
          "**/*.{css,html}"
        ]
      },
      {
        "name": "vendor-bundle.js",
        "prepend": [
          "node_modules/bluebird/js/browser/bluebird.core.js",          
          "scripts/lib/require.js"
        ],
        "dependencies": [
          "aurelia-binding",
          "aurelia-bootstrapper",
          "aurelia-dependency-injection",
          "aurelia-event-aggregator",
          "aurelia-fetch-client",
          "aurelia-framework",
          "aurelia-history",
          "aurelia-history-browser",
          "aurelia-loader",
          "aurelia-loader-default",
          "aurelia-logging",
          "aurelia-logging-console",
          "aurelia-metadata",
          "aurelia-pal",
          "aurelia-pal-browser",
          "aurelia-path",
          "aurelia-polyfills",
          "aurelia-route-recognizer",
          "aurelia-router",
          "aurelia-task-queue",
          "aurelia-templating",
          "aurelia-templating-binding",
          {
            "name": "text",
            "path": "../scripts/lib/text",
            "packageRoot":  "../scripts/lib"
          },
          {
            "name": "aurelia-templating-resources",
            "path": "../node_modules/aurelia-templating-resources/dist/amd",
            "main": "aurelia-templating-resources"
          },
          {
            "name": "aurelia-templating-router",
            "path": "../node_modules/aurelia-templating-router/dist/amd",
            "main": "aurelia-templating-router"
          },
          {
            "name": "aurelia-breeze",
            "path": "../node_modules/aurelia-breeze/dist/amd",
            "main": "aurelia-breeze"
          },
          {
            "name": "breeze-client",
            "path": "../node_modules/breeze-client",
            "main": "breeze.debug"
          },
          {
            "name": "whatwg-fetch",
            "path": "../node_modules/whatwg-fetch",
            "main": "fetch"
          },
          {
            "name": "aurelia-testing",
            "path": "../node_modules/aurelia-testing/dist/amd",
            "main": "aurelia-testing",
            "env": "dev"
          },
          {
            "name": "icheck",
            "path": "../node_modules/icheck",
            "main": "icheck.min"
          },
          {
            "name": "filesaver.js",
            "path": "../node_modules/filesaver.js",
            "main": "FileSaver.min"
          }
        ]
      }
    ]
  }
}

我现在有一个问题。如果我跑

au build 

au run –watch

我没问题。 如果我跑

au build –env prod

创建app-和vendor-bundle - [标识符]。js,我没有得到任何错误,但是这两个文件最终都是空的,或者更确切地说是“undefined”它们。

Node.js版本:6.11.2(当前最新稳定版)

NPM版本:3.10.10

有没有人有想法?它是否与缩小机制有关(在开发中不会发生)

如何调试/记录出错的地方?

更新:

我已经为aurelia.json文件中的开发环境激活了缩小,这就是我得到的

Failed to write the bundle
SyntaxError: Unexpected token u in JSON at position 0
    at Object.parse (native)
    at new Converter (E:\Code\Application\XX-dev\XX.YY.Web\node_modules\aurelia-cli\lib\build\convert-source-map\index.js:42:48)
    at Object.exports.fromJSON (E:\Code\Application\XX-dev\XX.YY.Web\node_modules\aurelia-cli\lib\build\convert-source-map\index.js:96:10)
    at work.then (E:\Code\Application\XX-dev\XX.YY.Web\node_modules\aurelia-cli\lib\build\bundle.js:259:48)
    at process._tickDomainCallback (internal/process/next_tick.js:135:7)
{ uid: 8,
  name: 'writeBundles',
  branch: false,
  error:
   SyntaxError: Unexpected token u in JSON at position 0
       at Object.parse (native)
       at new Converter (E:\Code\Application\XX-dev\XX.YY.Web\node_modules\aurelia-cli\lib\build\convert-source-map\index.js:42:48)
       at Object.exports.fromJSON (E:\Code\Application\XX-dev\XX.YY.Web\node_modules\aurelia-cli\lib\build\convert-source-map\index.js:96:10)
       at work.then (E:\Code\Application\XX-dev\XX.YY.Web\node_modules\aurelia-cli\lib\build\bundle.js:259:48)
       at process._tickDomainCallback (internal/process/next_tick.js:135:7),
  duration: [ 5, 639721541 ],
  time: 1502969144275 }
{ uid: 0,
  name: '<series>',
  branch: true,
  error:
   SyntaxError: Unexpected token u in JSON at position 0
       at Object.parse (native)
       at new Converter (E:\Code\Application\XX-dev\XX.YY.Web\node_modules\aurelia-cli\lib\build\convert-source-map\index.js:42:48)
       at Object.exports.fromJSON (E:\Code\Application\XX-dev\XX.YY.Web\node_modules\aurelia-cli\lib\build\convert-source-map\index.js:96:10)
       at work.then (E:\Code\Application\XX-dev\XX.YY.Web\node_modules\aurelia-cli\lib\build\bundle.js:259:48)
       at process._tickDomainCallback (internal/process/next_tick.js:135:7),
  duration: [ 47, 444524559 ],
  time: 1502969144277 }
SyntaxError: Unexpected token u in JSON at position 0
    at Object.parse (native)
    at new Converter (E:\Code\Application\XX-dev\XX.YY.Web\node_modules\aurelia-cli\lib\build\convert-source-map\index.js:42:48)
    at Object.exports.fromJSON (E:\Code\Application\XX-dev\XX.YY.Web\node_modules\aurelia-cli\lib\build\convert-source-map\index.js:96:10)
    at work.then (E:\Code\Application\XX-dev\XX.YY.Web\node_modules\aurelia-cli\lib\build\bundle.js:259:48)
    at process._tickDomainCallback (internal/process/next_tick.js:135:7)

如果我为dev激活缩小,它也不起作用,给出上面粘贴的错误。如果我也删除了源图,它不起作用(两个包都未定义)但没有错误消息。

2 个答案:

答案 0 :(得分:0)

升级到最新版本的aurelia-cli npm模块(0.31.3),所有其他模块升级到最新版本,解决了这个问题。

答案 1 :(得分:-1)

我认为你现在可以做au build(没有--env prod标志。