imports-loader: Import loader create invalid variable name based off package name

Try importing jquery-migrate into a legacy jquery plugin, and you will get a compile error:

/node_modules/imports-loader/index.js?jQuery=jquery,this=>window,"jquery-igrate"!...node_modules/vh.jquery.ba-bbq/jquery.ba-bbq.js Unexpected token (4:4) You may need an appropriate loader to handle this file type. | var jQuery = require("jquery"); | (function() { | var "jquery-migrate" = require("\"jquery-migrate\""); | | /*!

My workaround is to create an alias but it would be nice if the import loader replaced invalid variable name characters with underscores or something.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 26 (15 by maintainers)

Most upvoted comments

Seems - to _ is good solution (also add docs about this).

That’s fine. 👍

This discussion is going in the wrong direction. imports-loader is for injecting values in this module’s scope, not put things in global just because you can’t find a local name.