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

"TypeError: u is undefined" when importing to browser from unpkg #2571

Closed
kqr opened this issue Jun 9, 2020 · 1 comment
Closed

"TypeError: u is undefined" when importing to browser from unpkg #2571

kqr opened this issue Jun 9, 2020 · 1 comment

Comments

@kqr
Copy link

kqr commented Jun 9, 2020

Reproduction

I'm trying to little by little integrate some more modern web UI paradigms into a big, legacy web application. I'm currently evaluating Preact as a React alternative. This being an old web application, there's no build system to speak of, and I'm not planning to start by introducing that.

I'm trying to import Preact with hooks in an ES6 module that is loaded by the browser. The import statements look (as instructed in previous issues in this repo) like this:

import { h, render } from 'https://unpkg.com/preact@latest?module';
import { useState, useEffect } from 'https://unpkg.com/preact@latest/hooks/dist/hooks.module.js?module';

Actual Behavior

Unfortunately, when my browser loads this module, it errors out with a message:

TypeError: u is undefined

It's a bit hard to figure out what's going on since the code imported is minified. On the one hand, it does look like a genuine problem with the code. On the other hand, when I try the same import statements in e.g. CodePen it seems to work.

Any idea what I could be missing?

@marvinhagemeister
Copy link
Member

It's a known bug in unpkg. It doesn't follow the node resolution algorithm correctly. See this issue: mjackson/unpkg#197

Use pika.dev or npm.reversehttp.com instead. They work correctly.

Closing, duplicate of #2564 #2439 #1961 .

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