guardian / scribe

DEPRECATED: A rich text editor framework for the web platform
http://guardian.github.io/scribe/
Apache License 2.0
3.51k stars 245 forks source link

cjs version scribe@4.0.0 does not work with browserify w/ deamdify #514

Open simonfan opened 6 years ago

simonfan commented 6 years ago

The polyfill introduced at https://github.com/guardian/scribe/pull/496 (polyfill for lodash-amd/modern/string/escape) breaks compatibility with the cjs browserify w/ deamdify build process.

The problem seems to be that the polyfilled module (defined at src/plugins/core/formatters/plain-text/escape-html-characters.js) has multiple AMD module definitions in one single file which breaks the way deamdify works (by taking the first anonymous module defined in the file and transforming it into a cjs module).

A simple solution would be to flatten the module dependencies in this file and put all functions into a single module. Here is my basic implementation that got it working.

Maybe I am missing some other parts of the code that depend on these modules, but running a simple search through the source code I could not find any code depending explicitly on either lodash or the submodules defined on the polyfill's file lodash-amd/modern/internal/baseToString, lodash-amd/modern/internal/escapeHtmlChar, lodash-amd/modern/string/escape or lodash-amd/modern/string/escape. It seems that those are only internal dependencies of the submodule.

I would love to help to get this working and would like to hear your opinion on this :)