I am trying to reorganize a library using Browserify by smoothing some modules from the package by scrolling the browser. In particular, the library uses require ("codemirror"), but I want to provide a package that does not include CodeMirror, but rather uses the one provided through the CDN.
So, I have a browser-shim setting in my package.json, for example
"browserify-shim": { "jquery": "global:jQuery", "codemirror": "global:CodeMirror" }
So far so good. require ('jquery') and require ('codemirror') disappeared from the numbered package and were replaced with the expected code fragment to capture jQuery and CodeMirror from the window object.
The library also requires some CodeMirror add-ons. For example, require ('codemirror / addon / hint / show-hint.js'). It's great. I want this add-on bundled. However, inside this add-on there is a UMD shell that includes require ("../../lib/codemirror"). Browserify sees this and associates CodeMirror with / node_modules / codemirror / lib / codemirror.js because of this (I think). I want this to use window.CodeMirror as defined in the codemirror encoding instead, but cannot figure it out. Tried a lot of options, including:
"browserify-shim": { "jquery": "global:jQuery", "codemirror": "global:CodeMirror", "../../lib/codemirror": "global:CodeMirror", "codemirror/addon/hint/show-hint.js": { "exports":null, "depends":["../../lib/codemirror:CodeMirror"] } }
What is required ("../../lib/codemirror") will not disappear! I'm sure something is missing for me.
I run this from a Gulp script, but I don't think it should matter. Browser version 3.38.1. Browserify-shim version 3.7.0.
Any ideas?
source share