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 command not working #93

Closed
Wazrop opened this issue Oct 1, 2024 · 3 comments · Fixed by #103
Closed

Watch command not working #93

Wazrop opened this issue Oct 1, 2024 · 3 comments · Fixed by #103
Labels
bug-windows A bug for windows OS

Comments

@Wazrop
Copy link

Wazrop commented Oct 1, 2024

Hello,

When using watch flag with assetpack assetpack -w it throws and error RangeError: Maximum call stack size exceeded.

C:\assetpack-test> npm run watch-assets

> watch-assets
> assetpack -w

› Info: [AssetPack] cache found.                                                                                                                                                                                                                                                   
✔ AssetPack Initialized
› Building: C:/assetpack-test/raw-assets
|                                          | 0%C:\assetpack-test\node_modules\upath\build\code\upath.js:34
  p = p.replace(/(?<!^)\/+/g, "/");
        ^

RangeError: Maximum call stack size exceeded
    at String.replace (<anonymous>)
    at toUnix (C:\assetpack-test\node_modules\upath\build\code\upath.js:34:9)
    at C:\assetpack-test\node_modules\upath\build\code\upath.js:46:20
    at Array.map (<anonymous>)
    at Object.dirname (C:\assetpack-test\node_modules\upath\build\code\upath.js:44:21)
    at AssetWatcher._ensureDirectory (file:///C:/assetpack-test/node_modules/@assetpack/core/dist/core/AssetWatcher.js:196:33)
    at AssetWatcher._ensureDirectory (file:///C:/assetpack-test/node_modules/@assetpack/core/dist/core/AssetWatcher.js:200:14)
    at AssetWatcher._ensureDirectory (file:///C:/assetpack-test/node_modules/@assetpack/core/dist/core/AssetWatcher.js:200:14)
    at AssetWatcher._ensureDirectory (file:///C:/assetpack-test/node_modules/@assetpack/core/dist/core/AssetWatcher.js:200:14)
    at AssetWatcher._ensureDirectory (file:///C:/assetpack-test/node_modules/@assetpack/core/dist/core/AssetWatcher.js:200:14)

Node.js v22.1.0

package.json

{
  "type": "module",
  "scripts": {
    "assets": "assetpack",
    "watch-assets": "assetpack -w"
  },
  "devDependencies": {
    "@assetpack/core": "^1.1.1"
  }
}


.assetpack.js

export default {
  entry: "./raw-assets",
  output: "./public/assets",
  ignore: ["**/*.html"],
  cache: true,
  cacheLocation: ".assetpack",
  logLevel: "info",
};

@Zyie
Copy link
Member

Zyie commented Oct 1, 2024

hmm I think this might be a windows specific issue

I don't have a windows machine right now, so are you able to change this line of code:

if (parentPath === this._entryPath || parentPath === '.' || parentPath === '/')

to this:
if (parentPath === this._entryPath || parentPath === '.' || parentPath === '\\')

@Wazrop
Copy link
Author

Wazrop commented Oct 1, 2024

Tried it but the parentPath is always C:/ so I checked it against current path, like this:

if (parentPath === this._entryPath || parentPath === '.' || parentPath === dirPath)

It successfully goes out of the recursion but it dies when adding child:

PS C:\assetpack-test> npm run watch-assets

> watch-assets
> assetpack -w

› Info: [AssetPack] cache found.                                                                                                                                                                                                                                                                              
✔ AssetPack Initialized
› Building: C:/assetpack-test/raw-assets
|                                          | 0%test: C:\assetpack-test\raw-assets C:/assetpack-test
test: C:/assetpack-test C:/
test: C:/ C:/
file:///C:/assetpack-test/node_modules/@assetpack/core/dist/core/AssetWatcher.js:211
        parentAsset.addChild(asset);
                    ^

TypeError: Cannot read properties of undefined (reading 'addChild')
    at AssetWatcher._ensureDirectory (file:///C:/assetpack-test/node_modules/@assetpack/core/dist/core/AssetWatcher.js:211:21)
    at AssetWatcher._ensureDirectory (file:///C:/assetpack-test/node_modules/@assetpack/core/dist/core/AssetWatcher.js:201:14)
    at file:///C:/assetpack-test/node_modules/@assetpack/core/dist/core/AssetWatcher.js:130:22
    at Array.forEach (<anonymous>)
    at AssetWatcher._applyChangeToAssets (file:///C:/assetpack-test/node_modules/@assetpack/core/dist/core/AssetWatcher.js:120:17)
    at AssetWatcher._updateAssets (file:///C:/assetpack-test/node_modules/@assetpack/core/dist/core/AssetWatcher.js:114:14)

Node.js v22.1.0

@Zyie
Copy link
Member

Zyie commented Oct 1, 2024

ok thank you for trying!
I should be able to test this on a windows machine later in the week, so will look into it then!

@Zyie Zyie added the bug-windows A bug for windows OS label Oct 1, 2024
@Zyie Zyie linked a pull request Nov 19, 2024 that will close this issue
@Zyie Zyie closed this as completed Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-windows A bug for windows OS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants