wenzhixin / bootstrap-table

An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation, Vue.js)
https://bootstrap-table.com/
MIT License
11.7k stars 4.44k forks source link

Issue when trying to run esbuild bundle #7380

Closed LukaszPiatkowski27 closed 5 days ago

LukaszPiatkowski27 commented 1 month ago

Bootstraptable version(s) affected

1.23.0

Description

trying to run this command esbuild app/javascript/*.* --bundle --sourcemap --outdir=app/assets/builds --public-path=/assets throws the following error: image

Using version 1.22.6 there is no issue

Example(s)

No response

Possible Solutions

No response

Additional Context

No response

UtechtDustin commented 4 weeks ago

I never heard of esbuild, but it seems it's an bundler like webpack etc. ?
I'm not sure if we can help with that issue. @wenzhixin do you used it before ?

@LukaszPiatkowski27 i guess you already tried to find a solution on google or in the esbuild community ? The chance is high, that this is an issue of esbuild as other bundler works fine.

jnimety commented 4 weeks ago

FWIW esbuild is at least used by vite, and other bundlers if I recall correctly.

That said, it looks like boostrap-table is missing a dependency on core-js. My copy of node_modules/bootstrap-table/dist/bootstrap-table.js has many references to core-js and I don't see core-js in node_modules/bootstrap-table/package.json. I too was getting "Could not resolve" errors when building with vite/esbuild and adding core-js to my package.json fixed the errors.

HealthyPizza commented 3 weeks ago

Similar issue with symfony asset:mapper, and another project with yarn.

No issue when locking at 1.22.6

image

LukaszPiatkowski27 commented 3 weeks ago

@UtechtDustin Yes, It's a bundler, webpack alternative. I did search for a solution, but didn't find anything (ofc adding core-js manually works, but that's just not a solution in my case). You can see that the core-js dependency is missing for more people.

UtechtDustin commented 3 weeks ago

Oh okay, thanks for the informations! I guess i found the issue, as we use babel-preset-env which then uses polyfills using core-js.

The Problem is i can't submit a PR for that, as the bootstrap-table currently uses yarn as dependency manager and i stopped using yarn 2 years ago and switched back to npm. As i don't see huge advantages to use yarn instead of npm right now. We just add a layer on top (also the installation and version management is quit shit - in my opinion - on the newest yarn version). @wenzhixin What is the reason, that we use yarn instead of npm ? Could we switch to npm ?

jnimety commented 1 week ago

Any update on this? IMHO a separate issue should be opened to discuss package manager preferences and in the meantime the proper dependencies can be added using yarn.

wenzhixin commented 1 week ago

@wenzhixin do you used it before?

I have not used esbuild before, either.

However, I followed the following steps to test it:

Create a file main.js

import 'bootstrap-table'

I think you can solve your problem using the following method, and I will also investigate whether there is a better way.

You can add core-js and jquery in your package.json to solve the problem.

npx esbuild src/main.js --bundle --sourcemap --outdir=builds

  builds/main.js      548.8kb
  builds/main.js.map  910.6kb

⚡ Done in 65ms
UtechtDustin commented 1 week ago

@wenzhixin We just have to add core-js as dependency to our package.json and the issue should be fixed. As i mentioned above i can't submit a PR as we still using yarn and not npm, is there a reason for that ?

wenzhixin commented 1 week ago

My idea is to improve the build script without dependency on core-js.

wenzhixin commented 5 days ago

Adding core-js to devDependencies can solve the problem, and the built files in dist will not require core-js at all.