Comments (8)
that would be nice!
In the meantime if you want to use inject-loader with babel7, you can use @babel/plugin-transform-modules-commonjs.
It will transform the modules to commonjs so the loader will work
from inject-loader.
@matteoantoci Hey thanks for the report, I’ll try and find time to have a look :)
from inject-loader.
I opened a couple PRs that should help out here:
#73 adds ESM support so you no longer have to transform your modules to CJS format before running them through inject-loader
#74 includes #73 and upgrades to Babel 7.
Would love it if someone could try out the ESM feature in either PR to help identify any use cases I may have missed.
from inject-loader.
Had the very same issue, we just migrated to Babel 7, @babel/plugin-transform-modules-commonjs came to rescue. Thanks alot!
If not dependant on module: "esnext" - module: "commonjs" in tsconfig does the trick too.
from inject-loader.
Thanks tl;dr of this is that inject-loader operates on CJS modules only (at the moment anyway), so any code you want to inject needs to be compiled to CJS before inject-loader can operate on it. This should probably be documented better and/or an example for Babel 7.
from inject-loader.
from inject-loader.
Hey' We are currently migrating to Babel 7.5.5 and Webpack 4.35.3 and we ran into some problem with some of our tests which needs inject-loader
.
As soon as I add the import SomeComponent from 'inject-loader!.';
and run the tests it will print an error that it doesn't know about the object rest/spread operator (whereas babel preset env is properly configured and set to the correct node version).
Compiling the same file via babel cli works without an error. It seems that the babel configuration is not used by inject loader. (the same setup works with Babel 6 with Webpack 3)
I've tried to explicitly add the @babel/plugin-proposal-object-rest-spread
plugin as well without any success. Also tried to add babel as an inline loader like babel-loader!inject-loader!.
/ !inject-loader!babel-loader!.
Is there a workaround for this for now?
When can we expect Babel 7 support?
from inject-loader.
I was able to work around this issue by upgrading inject-loader
to @seanparmelee's babel 7 fork seanparmelee@fcd20ba at and then setting babel-preset-env's modules
to commonjs
for my test env
{
"env": {
"test": {
"presets": [
[
"@babel/preset-env",
{
"modules": "commonjs"
}
]
]
}
}
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
- 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.