Comments (9)
I have a feeling this is due to the $'
which is being parsed as a regex match when performing the injection. Pull request #31 refactored the code to use a string replace which should fix this issue.
In the meantime, you can use double quotes or string literals as a workaround.
I'll also write a test to cover this case.
from inject-loader.
@rmp135 you are right, $'
-> $"
did the trick. Thank you!
from inject-loader.
If someone is affected by the same or similar issue - i just wrote injectify-loader which has the same api/behaviour, but using babel
tools under the hood (instead of regular expressions). I was able to just replace inject-loader
with injectify-loader
in my project - and everything was working like a charm.
from inject-loader.
@vladimir-tikhonov Hey, that’s pretty cool—nice work! I’d kinda been meaning to explore something like that for this module given the ubiquity of babel these days (was not the case as much back when I first wrote inject-loader
), and the hackiness of using regex. Would you consider a PR?
from inject-loader.
@plasticine I've written injectify-loader
from scratch, so the only type of pr I can submit is "remove everything from inject-loader
/ add everything from injectify-loader
"
from inject-loader.
@vladimir-tikhonov Heh, fair enough :simple_smile: I suspect the next time I get a chance to do some OSS stuff I’ll probably be looking at going in the same direction in this project anyway, but I can certainly understand that you might want to keep injectify-loader
as a separate project.
In the meantime, @rmp135 is correct in stating that his PR #31 should resolve the above issue.
from inject-loader.
@plasticine I just wanted to state that these projects have many differences, so if I submit a pr it will be a complete rewrite of this package. However, I can definitely do this, if you are ok with that. Moreover, I think that having only one package that does the right thing is much better for the js community.
from inject-loader.
@vladimir-tikhonov nah, I would not be opposed to that at all — this project has never really been a very complex idea or implementation, and your implementation is really great.
I would love to be able to rule out a whole category of bugs (i.e this one) that come from hacky regexes, by adopting babel to transform code instead (it may also allow for fixing #17 finally!). I think adopting babel for this task is really probably the right move.
If you’re willing, I’d love to work on getting your improvements across.
from inject-loader.
@plasticine okie dokie, I'll submit a pr in a couple of days
from inject-loader.
Related Issues (20)
- Thanks HOT 1
- Not working for me HOT 3
- Webpack + coffeescript + inject-loader HOT 2
- Cannot find module HOT 18
- Any chance of transitive dependencies ? HOT 2
- Webpack 3 compatibility HOT 2
- Regression: When injecting a falsey export, it shouldn't fall back to real module HOT 3
- babelrc config not used HOT 1
- Not working with React Native packager? HOT 1
- Support code-coverage instrumentation HOT 2
- Add webpack v4 to peerDependencies HOT 2
- Work with Jest HOT 3
- Mocking out the 'request-promise' library HOT 1
- Add more tests HOT 1
- Calling require() with dynamically formed paths leads to runtime issue with webpack
- Cannot mock default and named exports together HOT 1
- Add support for Babel 7 HOT 8
- Nested dependencies? HOT 1
- TS-support
- Webpack version 5.x support? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from inject-loader.