samrith-s / parcel-plugin-structurize

A plugin to customize the output (dist) directory structure during production.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[πŸ›] Bug: no such file or directory

aivchen opened this issue Β· comments

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

  • Package version: checked all 2.X.X versions
  • Node version: 15.8.0
commented

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.

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. πŸ˜„

Indeed! Sorry for this confusion:)

@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:

chalk`{yellow The plugin "parcel-plugin-custom-dist-structure" has encountered an error.}`,

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.

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?

@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.

@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.

@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!

@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.

commented

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.

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

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.