question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Import loader create invalid variable name based off package name

See original GitHub issue

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.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
bebrawcommented, May 20, 2017

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

That’s fine. 👍

1reaction
Jessidhiacommented, May 17, 2017

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solved: Variable Naming Error when importing data sets
You have CSV file. If you have the VALIDVARNAME option set to V7 then PROC IMPORT will generate valid SAS names from the...
Read more >
5. The import system — Python 3.11.1 documentation
When a regular package is imported, this __init__.py file is implicitly executed, and the objects it defines are bound to names in the...
Read more >
Python import: Advanced Techniques and Tips
In this tutorial, you'll learn how to: Use modules, packages, and namespace packages; Handle resources and data files inside your packages; Import modules ......
Read more >
invalid-name / C0103 - Pylint 2.16.0-dev documentation
Description: Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...). Additional details:
Read more >
How do I convert a string to a valid variable name in Python?
You can use the built in func: str.isidentifier() in combination with filter() . This requires no imports such as re and works by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found