Giter Club home page Giter Club logo

Comments (7)

rschristian avatar rschristian commented on June 14, 2024

I cannot reproduce from the provided repo. It seemingly builds just fine? As far as I can see you don't even use the one route? Please double check that reproduction.

I should point out that your app breaks hooks; you cannot call hooks conditionally, in React or Preact. This is one of their intrinsic rules. Things like this will break your app:

if (typeof window !== 'undefined') {
    mobile = useMediaQuery('(max-width: 520px)');
}

from preact-cli.

PPHelios avatar PPHelios commented on June 14, 2024

I am very sorry @rschristian I sent you wrong index.js file, I fixed it and removed all conditional hook calls even for translation to further simplify testing, but every thing works fine when not route importing, and in both cases no errors are produced during dev or build, it happens when I upload the static build to the host (hostinger), I will include two links for both cases .

route_splitting_issue.zip

Route import ( produces issue ): https://dev8.bdoonwasyt.com/
Normal import ( works fine ): https://dev9.bdoonwasyt.com/

thanks in advance!

from preact-cli.

rschristian avatar rschristian commented on June 14, 2024

Have you tested using the serve command locally? That will spin up a server to test the output of the build command.

There's nothing I can do to help you with that deployed site. I need source code.

from preact-cli.

PPHelios avatar PPHelios commented on June 14, 2024

Have you tested using the serve command locally? That will spin up a server to test the output of the build command.

There's nothing I can do to help you with that deployed site. I need source code.

serve logs the same error
route_splitting_issue.zip

from preact-cli.

rschristian avatar rschristian commented on June 14, 2024

You still have conditional hooks:

// routes/login/index.js

if (typeof window !== "undefined") {
    form = useForm({
      ...
    });
}

This fundamentally isn't allowed in React or Preact and it will completely break hooks in your app. You can read more here.

Your provided app does not build out-of-the-box, it's seemingly missing dependencies, and iss all of that i18n stuff needed? Those dependencies cause a dead-lock on the build process, something's not configured right.

from preact-cli.

rschristian avatar rschristian commented on June 14, 2024

I should also mention that you probably should look to use Vite, not Preact-CLI, for your Preact apps. We haven't been able to maintain this as much as we'd like and Webpack hasn't kept up well.

We have a Vite initializer which you can use by running npm init preact, it'll give you a few options before setting up your new project.

from preact-cli.

rschristian avatar rschristian commented on June 14, 2024

Closing, hopefully its been addressed.

from preact-cli.

Related Issues (20)

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.