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).
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 :)
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 filelodash-amd/modern/internal/baseToString
,lodash-amd/modern/internal/escapeHtmlChar
,lodash-amd/modern/string/escape
orlodash-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 :)