samrith-s / parcel-plugin-structurize

A plugin to customize the output (dist) directory structure during production.
MIT License
41 stars 6 forks source link

[🐛] Bug: no such file or directory #31

Closed aivchen closed 3 years ago

aivchen commented 3 years ago

Describe the bug

  1. Checkout this repo: https://github.com/aivchen/html2
  2. yarn install
  3. yarn build

Error messages

  The plugin "parcel-plugin-custom-dist-structure" has encountered an error.

  Error: ENOENT: no such file or directory, open '/home/andrew/web/html/dist/1.html'

Expected behavior

Successful build without errors

Information

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

samrith-s commented 3 years ago

Hey @aivchen

Then error is not from this plugin. It is from the other plugin which performs the same function: parcel-plugin-custom-dist-structure

I think you have some residual dependencies in your node_modules from when the other plugin was installed. Maybe try deleting your node_modules folder and your *.lock file and re-installing dependencies.

Closing this issue as it is not related to this project. But please feel free to create another one if you find any issues with this plugin. 😄

aivchen commented 3 years ago

Indeed! Sorry for this confusion:)

aivchen commented 3 years ago

@samrith-s hmmm. Investigated the issue. Seems it's not related to another plugin. I've set up a clean docker container and the error still exists.

Besides, I see a string "parcel-plugin-custom-dist-structure" in the source code of your library: https://github.com/samrith-s/parcel-plugin-structurize/blob/36c984da1efd46a225584b603052bd22f56262ef/src/logs.ts#L32

samrith-s commented 3 years ago

Ah i completely forgot about that. That's some residual code from when I was going to name this plugin the same as the other one before I found that one 😄

Could you please provide your error stack? It'll help debug better.

aivchen commented 3 years ago

That's all I have (verbose and displayAssetsMap are set to true in the package.json):

 ./node_modules/.bin/parcel build --log-level 5 src/index.html
[3:26:42 PM]: Building...

[3:26:43 PM]: Building index.html...
[3:26:43 PM]: Building 1.html...
[3:26:43 PM]: Built page/1.html...
[3:26:43 PM]: Built index.html...
[3:26:43 PM]: Producing bundles...
[3:26:43 PM]: Packaging...
[3:26:43 PM]: ✨  Built in 70ms.
[3:26:43 PM]: 
[3:26:43 PM]: dist/index.html     323 B    3ms
[3:26:43 PM]: dist/page/1.html      0 B    1ms

  parcel-plugin-structurize
  Config: /tmp/html2/package.json

  The plugin "parcel-plugin-custom-dist-structure" has encountered an error.

  Error: ENOENT: no such file or directory, open '/tmp/html2/dist/1.html'

  If you think this is a bug, use this link to report it on Github.
  http://bit.ly/parcel-plugin-structurize-bug

Have you tried my test repo (https://github.com/aivchen/html2)? Does it build successfully for you?

aivchen commented 3 years ago

@samrith-s Just noticed that in the output parcel-plugin-structure is looking for the file 1.html in /tmp/html2/dist directory. But the real directory of this file is /tmp/html2/dist/page/.

So it must be a wrong logic in working with subdirectories.

samrith-s commented 3 years ago

@aivchen ~You can try it with v2.3.5 and let me know!~

Edit: Actually wait, I found another bug. Will work on it and figure out what's going wrong.

samrith-s commented 3 years ago

@aivchen I have some (possible) good news. You can check out this release v2.4.0 which ideally should address the issue in hand.

Please feel free to test and let me know!

aivchen commented 3 years ago

@samrith-s That's very good news! However, there is a special case when the plugin falls down.

It happens when there is an HTML tag for a static resource placed in the subfolder. For example:

<a href="./images/cat.jpeg">A cat</a>

And I get this:

Error: ENOENT: no such file or directory, rename '/tmp/html2/dist/cat.jpeg' -> '/tmp/html2/dist/images/cat.jpeg'

I've updated my repository https://github.com/aivchen/html2 if you want to test it.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

samrith-s commented 3 years ago

Hey @aivchen sorry for the extreme delay. This should be fixed soon.

samrith-s commented 3 years ago

So I had a look at this, and unfortunately there is no way to detect other meta information about the asset at the plugin level (whether it is referenced using img or a tag). The solution I had to this was too hacky and could cause a lot of other regressions. I'm going to keep it closed as this is not something I think is worth spending time right now. If you have any solutions, please don't hesitate to let me know.