-
Notifications
You must be signed in to change notification settings - Fork 46
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
Webpack failing to package balena-sdk in React/Next.js #1412
Comments
Hi, Lines 5 to 12 in e62c741
Can you try adding the following to your webpack.config.js and check whether helps? {
resolve: {
alias: {
'balena-sdk': path.resolve('./node_modules/pinejs-client-core/es2015'),
}
}
} |
Here is a fresh project with the issue: https://github.com/Nevter/BalenaSdkIssue/tree/main Will try make the webpack adjustments now. |
Modifying the webpack config (through next.config.mjs) seems to resolve the webpack issue, but the getSdk package export is now broken (although, this might be a typescript issue?)
|
Changing the files to .jsx files doesn't resolve this issue. Still seems to be webpack related: |
Can you provide us your
and/or add |
I was importing with
|
So, the issue isn't related to the LICENSE file itself, because if I remove that from the downloaded package in I have also verified this isn't working on another system: Do you get the same issue if you clone the repo I provided? |
I've also rolled back to a previous version of Next.js (v13.5.6) to see if the newest version of Next was adding some conflicting configs to webpack, but that version also fails with the same error. |
Oh @Nevter it seems that I gave you the wrong alias 😞 {
resolve: {
alias: {
'balena-sdk': path.resolve('./node_modules/balena-sdk/es2015')
}
}
} Give it a try and let us know.
Let me note again, that on our plain webpack project we do not face such issues, so I'm wondering whether this is b/c of the next.js defaults 🤔 An alternative to the aliases might be to explicitly limit webpack resolved files with: {
resolve: {
// Extensions to search for when requiring files.
extensions: ['.js', '.ts', '.tsx'], // and so on
} |
Hey @thgreasi That solves it! Overriding the webpack alias for both For completeness, this is now my
I don't have time to try it now, but it could also be React issue, over next.js configs? But it seems likely that one of those libs has some webpack configs that are causing the issue. This solves the issue, but it might be a good idea to either add this to the README or try hunt down the root cause so that others don't fall into the same trap. Thanks again for your help! |
That said, I just noticed that I get server-side error printed to console this during runtime:
|
Expected Behavior
Actual Behavior
On compilation, webpack cannot package the balena sdk. See following error:
It seems like webpack is failing to parse the LICENSE file. I'm unsure, but it might be beacuse of the tabs in the LICENSE file. Inspect other packages' LICENSE files, they don't have any tabs/ formatting. The error is with the " Apache License" line
One solution would be to override the webpack loader to deal with LICENSE files specifically, but this not an option in React.
Alterantively, the pre-packaged sdk can be used (balena-browser.min.js) but this is not an elegant solution, and means the sdk can only be used on the client side.
Steps to Reproduce the Problem
Specifications
References
The text was updated successfully, but these errors were encountered: