Closed dniccum closed 2 years ago
You're compiling the Statamic JavaScript?
You're compiling the Statamic JavaScript?
No I am not. I do have a custom field type that is being compiled in the cp.js
file.
Is your fieldtype using underscore?
Is your fieldtype using underscore?
No it is not.
If you're using lodash in that fieldtype it probably conflicts with Underscore that Statamic uses. Probably it's trying to take over the _
.
Oh yeah, you probably shouldn't use lodash. If we could go back in time, we would pick lodash. But we're stuck now.
We have experienced this issue just recently, in our particular example, it appears to be from https://github.com/jezzdk/statamic-wp-import/issues/2
In Chrome Dev Tools, you can view JS via the network tab and right click on any JS file/request and block the url, then refresh and that'll help narrow down the suspect JS, which in our particular case was public/vendor/statamic-wp-import/js/addon.js
@dniccum not sure if you ever sorted this, but I got around this by calling _.noConflict()
in my cp.js
:
import _ from 'lodash';
_.noConflict();
window.Statamic.booting(() => {
// ...
});
Hope that helps!
Bug description
After upgrading from Statamic 3.2.X to Statamic 3.3.X, I am now getting quite a few of Javascript errors within the CP views that indicate that there is an issue with the global inclusion of the Underscore.js library.
The errors that I have received:
_.findWhere is not a function
_.contains is not a function
How to reproduce
After upgrading a 3.2 Statamic website using the Peak Starter Kit to version 3.3, perform the necessary updates, and then compile all of your javascript.
Once the build is complete, visit any of the available collection entry edit views. I have also received this error some of the collection list views as well.
Logs
Versions
Installation
Starter Kit using via CLI
Antlers Parser
regex (default)
Additional details
My package.json file:
My mix file