Navigation Menu

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

Underscore fetched with bower stopped working #2923

Closed
kopernic-pl opened this issue Apr 15, 2021 · 10 comments
Closed

Underscore fetched with bower stopped working #2923

kopernic-pl opened this issue Apr 15, 2021 · 10 comments

Comments

@kopernic-pl
Copy link

There is a difference in how 1.13.0 fetches using NPM and bower.

npm package contains backward-compatibility underscore.js file (underscore-umd copy, as confirmed with diff)

C:\Temp\teststs\node_modules\underscore (underscore@1.13.0)
λ ls -l underscore*.js
-rw-r--r-- 1 user 1049089 68420 Oct 26 1985 underscore.js
-rw-r--r-- 1 user 1049089 65946 Oct 26 1985 underscore-esm.js
-rw-r--r-- 1 user 1049089 25711 Oct 26 1985 underscore-esm-min.js
-rw-r--r-- 1 user 1049089 19530 Oct 26 1985 underscore-min.js
-rw-r--r-- 1 user 1049089 68420 Oct 26 1985 underscore-umd.js
-rw-r--r-- 1 user 1049089 19530 Oct 26 1985 underscore-umd-min.js

bower, fetching directly from github, does not contain underscore.js file, which genreally breaks a lot.

bower underscore#* new version for https://github.com/jashkenas/underscore.git#*
bower underscore#* resolve https://github.com/jashkenas/underscore.git#*
bower underscore#* download https://github.com/jashkenas/underscore/archive/1.13.0.tar.gz
1.13.0.tar.gz does not contain underscore.js

Is it expected behavior?

@jgonggrijp
Copy link
Collaborator

No that was not expected and not intended. Thanks for reporting, @kopernic-pl!

I don't know much about Bower, to be honest; the bower.json file was already there when I took over maintenance and I never touched it. I'll look into it, but if you have any tips on how to solve the issue, please let me know.

@jgonggrijp
Copy link
Collaborator

@kopernic-pl I took a look at the bower.json, and it seems I actually updated it to use underscore-umd.js as the main entry instead of underscore.js. From what you're writing, I presume that Bower does not abstract away the main entry file name like Node.js does. The little documentation I could find about how to configure bower.json doesn't seem to give much room for specifying alternatives, aliases etcetera.

Seems like the only way to address this is to commit the duplicate underscore.js to git as well. If you can think of a more elegant solution, please let me know.

@kopernic-pl
Copy link
Author

No opinion on this one on my side - I'm just upkeeping some legacy project ;)

It's ok for me to use undescore-umd.js but I'm afraid that it will still break something somewhere, in some other projects.
If someone expects 'underscore.js' to be there and rely on this behavior/state, it's going to be rough.

Btw, symbolic links are no-go, so eventual copy seems to be only solution. Maybe name the file in the repo 'undescore.js' and automate renaming/creating copy to 'underscore-umd.js' when NPM package is created?

@kopernic-pl
Copy link
Author

Btw, the 'main' in bower.json just states which files from repository should be pulled to your lockal packages when doing bower init., as per bower spec

It does not do nothing with files renaming. Bower is prehistoric nowadays 👴

@7ochem
Copy link

7ochem commented Apr 15, 2021

I just ended up here because my build of a legacy project failed when uglifyjs reported it could not find bower_components/underscore/underscore.js while trying to build a vendors.min.js.

I'll point my uglifyjs config to underscore-umd.js for now (at least that's my take away from this thread here. I didn't know if I would need esm, node or umd 😄 🙈 )

@jgonggrijp
Copy link
Collaborator

@kopernic-pl I won't change the official name of the UMD build back to underscore.js; ESM is the future. However, I figured it wouldn't hurt to just commit a copy with the old name. Git works with a hash-based filesystem, so there shouldn't be a significant cost. Expect 1.13.1 in an hour or so.

@7ochem Thanks for chiming in. Your legacy project almost certainly needs the UMD build. I guess I should add some clarification about that to the documentation. If you have any suggestions for questions that you'd like to see answered with regard to that, please feel free to let me know.

@kopernic-pl
Copy link
Author

I've just pointed my code to umd package from 1.13.0 and it works very well (with require.js as a loader). So for me it is solved, for others @jgonggrijp copy shall be more than OK for next few years :)

@jgonggrijp
Copy link
Collaborator

@kopernic-pl @7ochem 1.13.1 is up.

@7ochem
Copy link

7ochem commented Apr 15, 2021

Thank you for the fast response and the ultra fast fix! 🙏🏻

@jgonggrijp
Copy link
Collaborator

Welcome!

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

3 participants