-
Notifications
You must be signed in to change notification settings - Fork 27
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
How to include in Preact no build #283
Comments
This is a known error in the module resolution code of See:
The recommended solution is to use a CDN which supports proper module resolution, like https://npm.reversehttp.com/ or https://www.skypack.dev/ <!DOCTYPE html>
<html>
<body>
<div id="app"></div>
<script type="module">
import "https://cdn.skypack.dev/preact/debug";
import { h, Component, render } from "https://cdn.skypack.dev/preact";
import htm from "https://cdn.skypack.dev/htm";
const html = htm.bind(h);
const app = html`<h1>Hello World!</h1>`;
render(app, document.getElementById("app"));
</script>
</body>
</html> |
I got this working by importing the submodule files directly, and using an import map for the <!DOCTYPE html>
<html>
<head>
<script type="importmap">
{
"imports": {
"htm": "https://unpkg.com/[email protected]?module",
"preact": "https://unpkg.com/[email protected]?module",
"preact/debug": "https://unpkg.com/[email protected]/debug/dist/debug.module.js",
"preact/devtools": "https://unpkg.com/[email protected]/devtools/dist/devtools.module.js"
}
}
</script>
</head>
<body>
<script type="module">
// Adding this line
import "preact/debug";
import { h, Component, render } from 'preact';
import htm from 'htm';
// Initialize htm with Preact
const html = htm.bind(h);
const app = html`<h1>Hello World!</h1>`;
render(app, document.body);
</script>
</body>
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why adding debug line to Preact (no build) simple page this error occurs
GET https://unpkg.com/[email protected]/devtools?module net::ERR_ABORTED 404
This is the simple code
The text was updated successfully, but these errors were encountered: