-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[docs] Using in nodejs without Polymer CLI / server #492
Comments
import("/node_modules/lit-element/lit-element.js"); or import("chrome-extension://hpoajfdeaoclodpipchameaccpjhccci/node_modules/lit-element/lit-element.js");
|
LitElement imports all dependencies with bare module specifiers, is this is the issue you're running into? If you look at lit-element.js you will see it tries to import AFAIK we don't have any experience with or recommendations for LitElement in NWjs :/ |
I found this article: https://polytuts.s-saleh.com/2016/05/19/polymer-nwjs-application/ this works with project, if path structure is:
But, if project have different structure like, i dont know, how correctly configure polymer.json
For my use, are relative paths natively. |
@panther7 I couldn't get that tutorial to work, something about trying to load an extension vs an app. However if you got the tutorial example working & your project structure is your only issue, you should just be able to configure the "sources" property in polymer.json I think. The docs are here: polymer.json specification but they are out of date (my bad). For the most up to date info on polymer.json options you might also need to take a look at the Tools repo
|
@katejeffreys I came across this issue via the Try LitElement page at https://lit-element.polymer-project.org/try. The StackBlitz embed does not render, nor does it render on the StackBlitz website. I multiple console errors:
So I tried to take the example code to CodePen: <!-- html: CodePen only allows <body> contents -->
<my-element></my-element> // js
import 'https://unpkg.com/@webcomponents/[email protected]/custom-elements-es5-adapter.js';
import 'https://unpkg.com/@webcomponents/[email protected]/webcomponents-bundle.js';
import {
LitElement,
html
} from 'https://unpkg.com/[email protected]/lit-element.js';
class MyElement extends LitElement {
render() {
return html`
<p>Hello world! From my-element</p>
`;
}
}
customElements.define('my-element', MyElement); But then I get this error in the console:
How can I try this in the browser? Is there a hosted version of LitElement that allows for native ES module importing? I'm using Chrome stable (73.0.3683.103) on macOS. |
lit-element needs to be implicitly imported as a module when using unpkg, correct? As in: |
@HyperPress Thanks for responding. If I add Now I get the following error:
|
@jsejcksn Info on the first error and a related issue on the StackBlitz repo. Just need to add an exception in Chrome content settings to permit cookies for CodePen also needs to do cookies, so if you can't control them because enterprise settings, maybe try one of the other browser options listed in the examples section of the README? The JS Bin one should work. |
@jsejcksn For the second error, I suspect this is to do with |
Allowing third-party cookies is not an option for me. It seems that Chrome stable supports all of the features afforded by the One more question: are there plans to provide a compiled |
I don't believe a pre-transpiled version is in the plans. But you could
just use polymer-cli to build an es5 compiled version and use that as a
default or use PRPL server. See pwa-starter-kit repo on GitHub for details.
I run a similar setup on local network.
|
I'm hoping that's not the case, so that students and developers who want to get started with LitElement will not need anything more than an evergreen browser. |
If you just need to support evergreen you can checkout pikapkg.
https://github.com/pikapkg/web/blob/master/README.md
It's sounds like a good solution if you focused on the basics of LitELement
lit-html.
|
@jsejcksn Unfortunately, it's not currently possible to load directly into the browser without either a build step or a server-side transform. There is a standards effort to close this gap, called "import maps". You can read about them here: https://github.com/WICG/import-maps In addition to polymer-cli, you can use build tools like Rollup or Webpack to transform the module specifiers. There's a Rollup config in this section: https://lit-element.polymer-project.org/guide/use The open-wc project also has default Rollup and Webpack configurations that work for LitElement projects: https://open-wc.org/building/#browser-standards I'm going to close this issue because we aren't going to add specific docs on running under NWjs. However, I think more detailed coverage of the tooling situation would supply the information you were originally looking for, and I've opened an issue for that work (#680). |
Hello,
i have desktop App project in NWjs (Chromium + Nodejs, like Electron). Is some best practise use lit-element in my project?
My probles are:
Solve is relative paths, because project context is
chrome-extension://
, examplechrome-extension://node_modules/lit-element/lit-element.js
The text was updated successfully, but these errors were encountered: