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

Bundling agent-js in a lib used webback projects leads to warnings #696

Closed
peterpeterparker opened this issue Mar 5, 2023 · 2 comments
Closed

Comments

@peterpeterparker
Copy link
Member

Is your feature request related to a problem? Please describe.
When agent-js is bundled within a lib that gets imported in Webpack projects, Webpack throws following errors:

Warning: Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

Describe the solution you'd like
Don't think it is a bug but, I am guessing it is a Polyfill thing. Therefore would appreciate any help resolving this issue.

On the lib side, Node libraries are pollyfied. I tried to create a library that do not use agent-js but process and buffer and no such warning was displayed. Issue popups when agent-js gets bundled.

e.g. library I used for testing contains only following code:

import {isDelegationValid} from '@dfinity/identity';

export const yolo = () => {
    console.log(isDelegationValid);
}

Note: peer dependencies is not an option.

Additional context

Repro

  1. Build a sample lib
git clone https://github.com/peterpeterparker/polyfill-lib
cd polyfill-lib
npm ci
npm run build
  1. in any Webpack based project
npm it /path/to/local/polyfill-lib

add following in code

import {yolo} from "polyfill-lib";
console.log(yolo);

and build

npm run build
@peterpeterparker
Copy link
Member Author

peterpeterparker commented Mar 5, 2023

It seems that if I build the library with vite / rollup I don't face the issue. I guess something in the esbuild setup of the lib therefore I close this (at least for now, not 100% sure).

@peterpeterparker
Copy link
Member Author

For the record, the type=module was missing in the package.json of my libs 🤦‍♂️

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