Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

fix: escape quotes in moduleIds to support webpack loaders #4

Merged
merged 1 commit into from
Mar 15, 2018

Conversation

mjneil
Copy link
Contributor

@mjneil mjneil commented Mar 15, 2018

webpack loaders can be activated with options that may contain quotes "
e.g. import style from 'css-loader?{"key":"value"}!style.css';

This change makes sure to escape any quotes in module ids so valid javascript is output

Address issue found here videojs/videojs-contrib-hls#600 (comment)

Copy link
Member

@gkatsev gkatsev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me.

@mjneil mjneil merged commit cd8cbbc into master Mar 15, 2018
@@ -188,10 +188,11 @@ var bundleWithWebpack = function(fn, fnModuleId) {
var modulesString;

if (devMode) {
fnModuleId = '"' + fnModuleId + '"';
// must escape quotes to support webpack loader options
fnModuleId = '"' + fnModuleId.replace(/"/g, '\\\"') + '"';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjneil why not ?

fnModuleId = JSON.stringify(fnModuleId);

looks much cleaner and does same thing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good call, that is nicer

@mjneil mjneil deleted the fix/webpack-loaders branch March 15, 2018 22:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants