AngelMunoz / Perla

A cross-platform tool for unbundled front-end development that doesn't depend on Node or requires you to install a complex toolchain
https://perla-docs.web.app/
MIT License
132 stars 11 forks source link

Cannot build esbuild bundle #82

Closed nojaf closed 2 years ago

nojaf commented 2 years ago

Describe the bug It appears the path used in

<script data-entry-point type="module" src="./App.js"></script>

Needs to exist on disk for esbuild to find it.

To Reproduce

I have a config like this:

{
  "$schema": "https://raw.githubusercontent.com/AngelMunoz/Perla/v0.22.1/perla.schema.json",
  "index": "./index.html",
  "fable": {
    "project": "./src/MyProject.App/MyProject.App.fsproj",
    "extension": ".js",
    "outDir": "./out"
  },
  "devServer": {
    "port": 8900,
    "mountDirectories": {
      "./out": "",
      "./out/fable_modules": "/fable_modules",
      "./images": "/images"
    },
    "useSSL": true,
    "watchConfig": {
        "directories": [ "./out", "./images" ]
    },
    "liveReload": true
  }
}

I'm mounting the physical out folder on the root and then i"m pointing my src="./App.js" of my data-entry-point to it.

Expected behaviour It would be nice if there was some validation of whether the file passed to esbuild exists. If it doesn't, it could look into the physical folder (out in my case) that is mapped to the root of the dev server.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

Mounting "./out": "", doesn't appear to include any subfolders. This might be a different bug or expected behaviour, I'm not sure.

AngelMunoz commented 2 years ago

if you switch the path of your script to

<script data-entry-point type="module" src="./out/App.js"></script>

does it work?

nojaf commented 2 years ago

Yes, that works for build but breaks during serve.

AngelMunoz commented 2 years ago

It would be nice if there was some validation of whether the file passed to esbuild exists. If it doesn't, it could look into the physical folder (out in my case) that is mapped to the root of the dev server.

Yeah, I think that's a good thing to check before starting the build

Yes, that works for build but breaks during serve.

What version are you on? I had an issue to mount directories on the root but it was for *nix systems and fixed in 0.22.1

Mounting "./out": "", doesn't appear to include any subfolders. This might be a different bug or expected behaviour, I'm not sure.

I'll have a look this week and see what I can do about it but it should mount everything under out, not just the first level

nojaf commented 2 years ago

What version are you on?

I'm on 0.22.1

Thanks for the quick response.

AngelMunoz commented 2 years ago

I have you a workaround in case you can actually work with "out" in the urls, testing with this config:

{
  "fable": {
    "autoStart": true,
    "project": "./src/App.fsproj",
    "extension": ".js",
    "outDir": "./out"
  },
  "devServer": {
    "mountDirectories": {
      "./out": "/out"
    }
  }
}
<!-- assuming that your sass script outputs to ./out/styles.css -->
<link rel="stylesheet" data-entry-point href="./out/styles.css" />

<script data-entry-point src="./out/Main.js" type="module"></script>

that should make it possible to both build and serve in this case "out" works as the usual "src" file so perhaps

the reason your directories were not working reclusively may be due the watchConfig option that you added. That config setting is very fragile and can break all of the detection I was planning to switch that eventually but haven't done anything there

nojaf commented 2 years ago

the reason your directories were not working reclusively may be due the watchConfig option that you added. That config setting is very fragile and can break all of the detection I was planning to switch that eventually but haven't done anything there

Not really sure I follow there, I would expect these to be different settings for different goals.

Your workaround will work but I've raised a PR with how I'd like to see it fixed. If you agree I can finish it up.

AngelMunoz commented 2 years ago

Not really sure I follow there, I would expect these to be different settings for different goals.

In dev we use a FileSystemWatcher which is a very limited API that doesn't support globbing patterns so one has to almost list by hand what do you want it to watch but you are right looking at the code it might have been something else.

Your workaround will work but I've raised a PR with how I'd like to see it fixed. If you agree I can finish it up.

Yes I don't mind, feel free to send it and I'll gladly merge and publish

AngelMunoz commented 2 years ago

The new version has been released! Once again thanks for this contribution

https://www.nuget.org/packages/Perla/0.23.0 https://github.com/AngelMunoz/Perla/releases/tag/v0.23.0