Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watch mode crashes on windows #111

Open
zackgomez opened this issue Jun 9, 2024 · 3 comments
Open

Watch mode crashes on windows #111

zackgomez opened this issue Jun 9, 2024 · 3 comments

Comments

@zackgomez
Copy link

The plugin consistently crashes for me on windows when I modify a watched file. I believe this is due to some path regularization.

My config

copy({
      resolveFrom: 'cwd',
      assets: [
        {
          from: './assets/profile_pics/*',
          to: './build/www/',
        },
        {
          from: './assets/card_images/*',
          to: './build/www/',
          watch: isDevServer,
        },
        {
          from: './assets/favicon.png',
          to: './build/www/',
        },
      ],
      verbose: true,
      watch: isDevServer,
    }),

Error in verbose mode (with an additional console.log added my me showing the undefined preserved dir structure

[watch-client] i [File Changed] File assets\card_images\ArtArcher.jpg changed, copy operation triggered.
[watch-client] i The from path ./assets/card_images/* of current asset pair doesnot ends with /**/*(.ext),
[watch-client] preservedDirStructure: undefined, globbedFromPath: assets\card_images\ArtArcher.jpg, startFragment: ./assets/card_images, sourcePath: C:\Users\Zack\Programming\mythos\assets\card_images\ArtArcher.jpg
[watch-client] file:///C:/Users/Zack/Programming/mythos/node_modules/esbuild-plugin-copy/dist/index.mjs:55
[watch-client]       preservedDirStructure.slice(1)
[watch-client]                             ^
[watch-client]
[watch-client] TypeError: Cannot read properties of undefined (reading 'slice')
[watch-client]     at copyOperationHandler (file:///C:/Users/Zack/Programming/mythos/node_modules/esbuild-plugin-copy/dist/index.mjs:55:29)      
[watch-client]     at file:///C:/Users/Zack/Programming/mythos/node_modules/esbuild-plugin-copy/dist/index.mjs:140:17
[watch-client]     at Array.forEach (<anonymous>)
[watch-client]     at FSWatcher.<anonymous> (file:///C:/Users/Zack/Programming/mythos/node_modules/esbuild-plugin-copy/dist/index.mjs:139:18)    
[watch-client]     at FSWatcher.emit (node:events:513:28)
[watch-client]     at FSWatcher.emitWithAll (C:\Users\Zack\Programming\mythos\node_modules\chokidar\index.js:540:8)
[watch-client]     at FSWatcher._emit (C:\Users\Zack\Programming\mythos\node_modules\chokidar\index.js:632:8)
[watch-client]     at listener (C:\Users\Zack\Programming\mythos\node_modules\chokidar\lib\nodefs-handler.js:389:18)
[watch-client]     at C:\Users\Zack\Programming\mythos\node_modules\chokidar\lib\nodefs-handler.js:271:49
[watch-client]     at foreach (C:\Users\Zack\Programming\mythos\node_modules\chokidar\lib\nodefs-handler.js:41:5)
[watch-client]
[watch-client] Node.js v18.12.1

Specifically looking at the log I added

preservedDirStructure: undefined, globbedFromPath: assets\card_images\ArtArcher.jpg, startFragment: ./assets/card_images, sourcePath: C:\Users\Zack\Programming\mythos\assets\card_images\ArtArcher.jpg

preservedDirStructure is undefined because the globbedFromPath = assets\card_images\ArtArcher.jpg is missing the prepended ./ and uses windows \ instead of my configs /.

@zackgomez
Copy link
Author

I can fix this locally by preresolving both of the variables

image

I can put up a PR if you would prefer

@graforlock
Copy link

graforlock commented Sep 1, 2024

@zackgomez I am experiencing the same.

Is there any other fix other than modifying this package in node_modules ?

@zackgomez
Copy link
Author

The correct solution would be to produce a corrected module by either updating this repo or forking and creating a new repo and package.

You could also "vendorize" the source tree with the fix. All of these solutions are much more annoying and less valuable than this repository being updated. It seems unmaintained or very sparsely maintained at best

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants