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

Cannot use glob pattern with wildcard in the middle of the path. #106

Open
benzsuankularb opened this issue Sep 8, 2023 · 2 comments
Open

Comments

@benzsuankularb
Copy link

benzsuankularb commented Sep 8, 2023

This pattern work

copy({
  resolveFrom: 'cwd',
  assets: {
    from: [
       '../../../../node_modules/my-package/build/assets/**/*',
    ],
    to: ['./build/assets'],
  }
})

But this doesn't

copy({
  resolveFrom: 'cwd',
  assets: {
    from: [
       '../../../../node_modules/**/build/assets/**/*',
    ],
    to: ['./build/assets'],
  }
})

And throws me a weird error...

i Resolve assert pair to path from: /workdir/packages/myproject/backends/standalone
i Watching mode enabled for all asset pairs, you can disable it by set watch to false in specified asset pairs
i Watching mode disabled. You need to enable build.watch option for watch mode to work.
✘ [ERROR] Cannot read properties of undefined (reading 'slice') [plugin plugin:copy]
    /workdir/node_modules/esbuild-plugin-copy/dist/index.js:84:28:
      84 │       preservedDirStructure.slice(1)
         ╵                             ^
    at copyOperationHandler (/workdir/node_modules/esbuild-plugin-copy/dist/index.js:84:29)
    at /workdir/node_modules/esbuild-plugin-copy/dist/index.js:152:17
    at Array.forEach (<anonymous>)
    at executor (/workdir/node_modules/esbuild-plugin-copy/dist/index.js:151:18)
    at /workdir/node_modules/esbuild-plugin-copy/dist/index.js:173:13
    at async /workdir/node_modules/esbuild/lib/main.js:1494:27
  This error came from the "onEnd" callback registered here:
    /workdir/node_modules/esbuild-plugin-copy/dist/index.js:106:22:
      106 │       build[applyHook](async () => {
          ╵                       ^
    at setup (/workdir/node_modules/esbuild-plugin-copy/dist/index.js:106:23)
    at handlePlugins (/workdir/node_modules/esbuild/lib/main.js:1292:21)
    at buildOrContextImpl (/workdir/node_modules/esbuild/lib/main.js:978:5)
    at Object.buildOrContext (/workdir/node_modules/esbuild/lib/main.js:786:5)
    at /workdir/node_modules/esbuild/lib/main.js:2196:68
    at new Promise (<anonymous>)
    at Object.context (/workdir/node_modules/esbuild/lib/main.js:2196:27)
    at Object.context (/workdir/node_modules/esbuild/lib/main.js:2036:58)
    at build (/workdir/packages/myproject/backends/standalone/build.js:16:33)
/workdir/node_modules/esbuild/lib/main.js:1649
  let error = new Error(text);
              ^
Error: Build failed with 1 error:
/workdir/node_modules/esbuild-plugin-copy/dist/index.js:84:28: ERROR: [plugin: plugin:copy] Cannot read properties of undefined (reading 'slice')
    at failureErrorWithLog (/workdir/node_modules/esbuild/lib/main.js:1649:15)
    at /workdir/node_modules/esbuild/lib/main.js:1058:25
    at /workdir/node_modules/esbuild/lib/main.js:1525:9 {
  errors: [Getter/Setter],
  warnings: [Getter/Setter]
}
@benzsuankularb
Copy link
Author

benzsuankularb commented Sep 8, 2023

More investigation,
Seems like a multiple assets pattern with no middle wildcard this didn't work as well...

This work

copy({
  resolveFrom: 'cwd',
  assets: {
    from: [
      '../../../../node_modules/my-package-1/build/assets/**/*',
    ],
    to: ['./build/assets'],
  }
})

This work

copy({
  resolveFrom: 'cwd',
  assets: {
    from: [
      '../../../../node_modules/my-package-2/build/assets/**/*',
    ],
    to: ['./build/assets'],
  }
})

This doesn't

copy({
  resolveFrom: 'cwd',
  assets: {
    from: [
      '../../../../node_modules/my-package-1/build/assets/**/*',
      '../../../../node_modules/my-package-2/build/assets/**/*',
    ],
    to: ['./build/assets'],
  }
})

@benzsuankularb
Copy link
Author

Oh, It's the same issue as
#105

Seems like this issue was opened a really while ago.

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

1 participant