1

我目前遇到的问题可能很简单,但我无法解决。

我有一个使用最新版本的 lit-element (2.0.1) 的聚合物应用程序。

不幸的是,在运行npm run build:static(后面是polymer build)并使用:(npm run serve:static 后面正在执行:)提供服务之后polymer serve --port 5000 build/es5-bundled

lit-element.js 不可用。

如果我列出项目 node_module 中的文件,我有:

pxke@station:ls -1 node_modules/lit-element/
CHANGELOG.md
lib
LICENSE
lit-element.d.ts
lit-element.d.ts.map
lit-element.js
lit-element.js.map
package.json
README.md
src

lit-element.js 似乎在那里,在构建之后,如果我查看构建的 node_module 它不会被复制。

g@station: ls -1 build/es5-bundled/node_modules/lit-element/
CHANGELOG.md
lib
LICENSE
lit-element.d.ts
lit-element.d.ts.map
lit-element.js.map
package.json
README.md
src

你知道为什么会这样吗?先感谢您。祝你有美好的一天!

以下是一些额外信息: package.json 的依赖部分

"dependencies": {
"@material/base": ">=0.3.6",
"@material/mwc-base": ">=0.3.6",
"@material/mwc-button": ">=0.4.0",
"@material/mwc-icon": ">=0.3.6",
"@material/mwc-ripple": ">=0.3.6",
"@material/ripple": ">=0.3.6",
"@polymer/app-layout": ">=3.0.0",
"@polymer/paper-button": ">=3.0.1",
"@polymer/polymer": ">=3.1.0",
"@webcomponents/webcomponentsjs": ">=2.2.4",
"browser-sync": "2.26.3",
"lit-element": ">=2.0.1",
"lit-html": ">=1.0.0",
"npm": "^6.9.0",
"pwa-helpers": "^0.9.0",
"redux": ">=4.0.0",
"redux-thunk": ">=2.3.0",
"reselect": "^4.0.0",
"sinon": "^4.5.0"
},

聚合物.json

{
  "entrypoint": "index.html",
  "shell": "src/components/test-app.js",
  "sources": [
    "images/**/*"
  ],
  "extraDependencies": [
    "manifest.json",
    "node_modules/@webcomponents/webcomponentsjs/**",
    "node_modules/lit-element/**",
    "node_modules/lit-html/**",
    "node_modules/@material/mwc-button/**",
    "node_modules/@material/mwc-base/**",
    "node_modules/@material/base/**",
    "node_modules/@material/mwc-ripple/**",
    "node_modules/@material/ripple/**",
    "node_modules/@material/mwc-icon/**",
    "push-manifest.json"
  ],
  "builds": [
    {
      "name": "esm-bundled",
      "browserCapabilities": [
        "es2015",
        "modules"
      ],
      "js": {
        "minify": true
      },
      "css": {
        "minify": true
      },
      "html": {
        "minify": true
      },
      "bundle": true,
      "addServiceWorker": true
    },
    {
      "name": "es6-bundled",
      "browserCapabilities": [
        "es2015"
      ],
      "js": {
        "compile": "es2015",
        "minify": true,
        "transformModulesToAmd": true
      },
      "css": {
        "minify": true
      },
      "html": {
        "minify": true
      },
      "bundle": true,
      "addServiceWorker": true
    },
    {
      "name": "es5-bundled",
      "js": {
        "compile": "es5",
        "minify": true,
        "transformModulesToAmd": true
      },
      "css": {
        "minify": true
      },
      "html": {
        "minify": true
      },
      "bundle": true,
      "addServiceWorker": true
    }
  ],
  "moduleResolution": "node",
  "npm": true
}
4

1 回答 1

1

通常,当您导入 lit-element 时,Polymer build可能会将 lit-element 代码捆绑到内置代码中。您可能看不到路径。但是如果你想强制添加路径,那么你可以polymer.jsonfragments. 例子:

聚合物.json:

{
  "entrypoint": "index.html",
  "shell": "src/components/test-app.js",
  "sources": [
    "images/**/*"
  ],
  "fragments": [
     "node_modules/lit-element/**/*",
  ],
  "sources": [
    "images/**/*"
  ],
  "extraDependencies": [
  ...
于 2019-03-22T17:45:07.463 回答