Skip to content
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

missing .js extensions cause failure to import in browsers #3

Open
chase-moskal opened this issue Dec 22, 2019 · 1 comment
Open

missing .js extensions cause failure to import in browsers #3

chase-moskal opened this issue Dec 22, 2019 · 1 comment

Comments

@chase-moskal
Copy link

chase-moskal commented Dec 22, 2019

hello!

i found this library recently, and it's really great work!

i noticed that when i inspect something like dialog.js: https://unpkg.com/browse/[email protected]/presenters/dialog/dialog.js

i find imports like these:

import Popover from '../popover'
import makeBtn from './make-btn'

however when a modern browser attempts to import a file which has imports like these, it will fail

to fix the issue and make the library more compatible with cutting-edge workflows, please add the .js extensions, like so

import Popover from '../popover.js'
import makeBtn from './make-btn.js'
  • traditional bundler tooling like rollup will ignore/tolerate the .js extensions
  • typescript itself also ignores/tolerates the .js extensions
  • webnative browser imports require the .js extensions
  • therefore, to best serve everybody, it's best to include the .js extensions across the board

note, you don't add the extensions to bare-specifiers like "lit-element" -- to be clear:

// correct to omit extension
import {LitElement} from "lit-element"

// correct to use extension
import {UpdatingElement} from "lit-element/lib/updating-element.js"

cheers, looking forward to using and evangelising these components wherever i can!

  👋😎 chase

@kjantzer
Copy link
Owner

Interesting, thanks for the info; I'll look into it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants