Closed chrisknoll closed 10 months ago
PrismJS is a bit of a complex dependency because it's loaded as a browser global, and any language component assumes the global has been instantiated.
This means that order matters, and you can't depend on an order when using define:
define(['prism','prismlanguages/prism-sql'], function () {
If you look at prism-sql.js, it starts with this:
Prism.languages.sql = {
if Prism hasn't been loaded, then you'll get an 'reference not found' when you call .languages
' on Prism.
So, we need to ensure that the core Prism component was loaded before the prism-sql loads. We can use shims for this:
},
"prism": {
exports: "Prism"
},
"prismlanguages/prism-sql": {
deps: ["prism"]
},
This will define 2 module ids: prism and prismlanguages/prism-sql, where we can indicate prism must load before the prism-sql.
With this, it's not required to include 'prism' as a dependency in define()
calls, referencing the language module will dpend on prism automatically.
define(['prismlanguages/prism-sql'], function () {
The hope is that the bundler will include these dependencies properly.
Update: it does.
Expected behavior
Prism ising shim config should adhere to shim config format.
Actual behavior
The shim config is defined as:
export should be directly below prism.