Code Monkey home page Code Monkey logo

simple's People

Contributors

developit avatar didierfranc avatar forsakenharmony avatar harshitkumar31 avatar jennydaman avatar johnstonbl01 avatar jortiz23 avatar lukeed avatar marvinhagemeister avatar mesaugat avatar nedt avatar pguilbert avatar prateekbh avatar reznord avatar rschristian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

simple's Issues

Cannot use global variable named `h`

Preparing the environment

I use preact-cli with the simple template:

preact create simple preact-bug-h
cd preact-bug-h
preact build

I verified that Hello, World! is displayed in the browser — as expected.

Problem 1: TypeError: h is not a function

Edit index.js and paste the following line before export default class App ...:

const h = 0;

Run preact build, get the following result:

TypeError: h is not a function
method: JkW7
at: /.../preact-bug-h/index.js:9:4

This error is quite explicit, but still it's not super obvious why h cannot be used here.

Problem 2: empty page is rendered silently

Edit index.js, and now define h to be a function, for example:

const h = () => {};

Run preact build, is finishes successfully. Open the result page in browser — now it appears to be empty.

Discussion

I'm sorry if this is a silly issue and thank you for looking into it. I also hope it's an appropriate place to raise the issue.

The default index.js only imports Component:

import { Component } from 'preact';

As I understand, h is injected when JSX is rendered by babel. This happens behind the scene, and we probably want developers to not worry about the mechanics of this process. However, I'm afraid that the chosen name might be a bit too common, especially in quick prototypes. Developers new to the ecosystem might get disoriented when their project suddenly stops working.

  • Maybe the template/index.js can be updated to also import h? The ticking clock demo on the getting started page does that, even though it's not being explicitly used. I personally don't think it's the best solution, but at least it gives a hint.

  • Maybe preact-cli can be reconfigured by default to use a different name, not h?

  • Maybe preact-cli documentation can be improved to mention the use of h?

{{ name }} isn't replaced

Th name isn't replaced when creating an app using:

preact create simple app

It's true for all the file I think, at least it's the case in the index.html as well as the manifest.
Version 2.0.1

Invalid source tree organisation after init

When initialised with npx preact-cli create simple myproject the artifacts are organised in a way that results in 404 on static assets and manifest.json. To solve this one has to move assets directory and manifest.json into src.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.