Open tpluscode opened 4 years ago
The issue I have with this approach is I'd like to maintain the ability to update codemirror by bumping the dep and running a simple command to copy the source files over. It would require re-running this modification after each update.
What I'd much much rather do is implicitly import any dependencies necessary using import.meta.url
. It looks like Webpack finally added import.meta support (after 2+ years of waiting) so that may be a viable option now.
Ex, if mode=javascript is selected then it should automatically add a script tag to the HTML header if one doesn't already exist there @therealadityashankar already has a way to handle this that guarantees there will be no dupes.
We could even modify the API to introduce a new language
attribute where you just have to specify which language will be used and the web component automagically handles all necessary imports. The same can be done for themes as well.
The real question is... Does webpack support for import.meta.url actually work?
I have the same problem with esbuild, any solution?
I want to use wc-codemirror with webpack and it's not possible to import a mode
This fails because the original source tries to
require('../../lib/codemirror')
.While I would not like to modify all those mode modules, I propose to create dummy commonjs (sic!) module at that path so that webpack and possibly other bundler can import do their thing
It can be simply
Ugly but it works