首页 > 解决方案 > 聚合物 3:聚合物构建后代码不起作用

问题描述

我的聚合物.json

{
  "entrypoint": "index.html",
  "shell": "src/boo-blogger/boo-blogger.js",
  "sources": [
    "images/*",
    "fonts/*"
  ],
  "extraDependencies": [
    "manifest.json",
    "node_modules/@webcomponents/webcomponentsjs/*.js",
    "node_modules/web-animations-js/web-animations-next-lite.min.js",
    "node_modules/@webcomponents/webcomponentsjs/bundles/*.js"
  ],
  "builds": [
    {
      "name": "es6",
      "bundle": true,
      "browserCapabilities": [
        "es2015",
        "modules"
      ],
      "js": {
        "minify": true,
        "transformModulesToAmd": true
      },
      "html": {
        "minify": true
      },
      "css": {
        "minify": true
      },
      "addServiceWorker": true
    }
  ],
  "npm": true,
  "lint": {
    "rules": [
      "polymer-3"
    ]
  }
}

我有问题

article-list.js:5 Uncaught (in promise) TypeError: _booBlogger.html$1 is not a function

article-list.js 通过路由动态导入。所以我尝试尝试一些不同的构建选项来构建。我发现当我在没有包的情况下构建时,构建的代码可以工作。我不知道为什么我的代码不能通过polymer build. 如果有人好奇这个问题并且需要完整的源代码。联络我

工具总结

  1. 系统:ubuntu 16.04
  2. 聚合物:1.7.7
  3. 节点:10.1.0

标签: buildpolymer-3.x

解决方案


在您的 polymer.json 中,您需要添加:

  "fragments": [
    "src/article-list.js"
  ],

推荐阅读