Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with WebPack 2 beta #14

Closed
sudsy opened this issue Aug 17, 2016 · 5 comments
Closed

Not working with WebPack 2 beta #14

sudsy opened this issue Aug 17, 2016 · 5 comments

Comments

@sudsy
Copy link

sudsy commented Aug 17, 2016

./~/inject-loader!../src/pages/calculators/module-ray-tracer/calc-module-ray-tracer/turboSimJobManager.js
Module parse failed: C:\Users\sudsy\Development\gen3\PVL.Content\tests\node_modules\inject-loader\index.js!C:\Users\sudsy\Development\gen3\PVL.Content\src\pages\calculators\module-ray-tracer\calc-module-ray-tracer\turboSimJobManager.js 'import' and 'export' may only appear at the top level (4:0)
You may need an appropriate loader to handle this file type.
| var module = {exports: {}};
| var exports = module.exports;
| import {Observable} from 'rxjs/Observable';
| import auth from "authentication";
| import connMgr from "modules/connection-manager/connection-manager";
@ ./unit-mocha/modules/SimJobManager/testTurboSimJobManager.js 3:0-110
@ ./unit-mocha/modules/SimJobManager/testTurboSimJobManager.js
@ multi main

@plasticine
Copy link
Owner

plasticine commented Sep 3, 2016

@sudsy Hey there, I think what is happening here is that you are perhaps trying to inject before you’ve transformed the code. This would mean that is you are writing code using es6 modules (as above), they are going to be moved inside the closure for injection — which as the error is indicating — is not allowed.

Please try running inject after and code transformations (e.g babel), and feel free to re-open if you’re still having issues. 👍

@sudsy
Copy link
Author

sudsy commented Sep 3, 2016

Hi Justin,

I'm not using babel at all. I'm using the native es6 module support from
Webpack 2.

I can't see how I can run the loader after the native transformations.

Sudsy

On Sat, 3 Sep 2016, 14:30 Justin Morris notifications@github.com wrote:

Closed #14 #14.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#14 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABjlh2BotsEbVmV8iuIsTu-KjRo-e7h7ks5qmPfbgaJpZM4JmICa
.

@plasticine
Copy link
Owner

I'm not using babel at all. I'm using the native es6 module support from
Webpack 2.

I can't see how I can run the loader after the native transformations.

Ahh, OK — I see. I’m not sure if I can support that use-case, at the moment only injecting CJS deps is supported. I’ll try and see if I can come up with an alternative.

@stayman
Copy link

stayman commented Feb 14, 2017

@plasticine is there any movement on this use case, I'd also be interested in this, and would be happy to collaborate on a PR if we could figure out a strategy that works.

@plasticine
Copy link
Owner

plasticine commented Feb 14, 2017

@stayman No movement as such — no.

To be honest I can’t see that it’s possible to support this use-case. The whole premise of inject-loader is to wrap the module-under-test in a closure in order to inject dependencies — something that is in conflict with es6 style modules where imports and exports must be at the top level.

For code under test I would suggest that you transform these imports to CJS style in order to use inject-loader, this should be pretty straight forward to isolate this transformation to only apply in test environments using babel-env or similar.

Most definitely open to other ideas, but as far as I can see that’s kinda where we’re at...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants