聚合物构建后未找到 lit-element.js
lit-element.js not found after polymer build
我目前遇到了一个可能很简单的问题,但我没有设法解决它。
我有一个使用最新版本的 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"
},
polymer.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
}
通常,当您导入 lit-element 时,Polymer build
可能会将 lit-element 代码捆绑到内置代码中。你可能看不到路径。但是如果你想强制添加路径,那么你可以在 fragments
下的 polymer.json
文件中定义。示例:
polymer.json:
{
"entrypoint": "index.html",
"shell": "src/components/test-app.js",
"sources": [
"images/**/*"
],
"fragments": [
"node_modules/lit-element/**/*",
],
"sources": [
"images/**/*"
],
"extraDependencies": [
...
我目前遇到了一个可能很简单的问题,但我没有设法解决它。
我有一个使用最新版本的 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"
},
polymer.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
}
通常,当您导入 lit-element 时,Polymer build
可能会将 lit-element 代码捆绑到内置代码中。你可能看不到路径。但是如果你想强制添加路径,那么你可以在 fragments
下的 polymer.json
文件中定义。示例:
polymer.json:
{
"entrypoint": "index.html",
"shell": "src/components/test-app.js",
"sources": [
"images/**/*"
],
"fragments": [
"node_modules/lit-element/**/*",
],
"sources": [
"images/**/*"
],
"extraDependencies": [
...