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

Loader.exec method does not eval loaders #667

Closed
kpdecker opened this issue Jan 8, 2015 · 16 comments
Closed

Loader.exec method does not eval loaders #667

kpdecker opened this issue Jan 8, 2015 · 16 comments

Comments

@kpdecker
Copy link
Contributor

kpdecker commented Jan 8, 2015

Hit a snag where trying to run the exec method on a require statement that has a loader in it, causing it to fail out.

Not sure what solutions are available here, but it would be nice to have loader require support within exec or document how to properly "polyfill require" that the val-loader alludes to.

@kpdecker
Copy link
Contributor Author

kpdecker commented Jan 8, 2015

To elaborate a little bit more, there is a loader that we have where we are trying to do a .exec to get css content. Within the content there is something along the lines of:

require('./foo.gif')

Which we have the proper loader mapping setup for but when run through exec it effectively runs require and tries to exec the gif data as if it were javascript.

@camshaft
Copy link

I ran into this as well. It would be great if exec used the same config as the parent compiler as well. I've tried prepending enhanced-require to the beginning of the source but it's having a hard time resolving some of the loaders.

@noxan
Copy link

noxan commented Jan 16, 2016

Had been struggling with this one for hours while trying to use to-string-loader or val-loader in combination with css-loader to handle url() statements in stylesheets and getting a plain string in return. Referenced this issue from the original one I filled for to-string-loader.

I would be willing to dig deeper into this one, but I am too familiar with the internals of webpack so far.

@tookko
Copy link

tookko commented Jan 26, 2016

+1 exactly same problem as @noxan here.

@kamilkp
Copy link

kamilkp commented Apr 15, 2016

+1

@kamilkp
Copy link

kamilkp commented Apr 15, 2016

Deriving from the parent config would be ideal but currently is there a way to hardcode a config into the .exec call to force it to use a proper loader?

@jessepollak
Copy link

I'm wondering about this same issue — has anyone made progress?

@dallas
Copy link

dallas commented Apr 27, 2016

+1 banging our heads against this same issue for a few hours now. Any resolution or guidance would be greatly appreciated!

@jessepollak
Copy link

I'm not sure if this will be helpful, but I ultimately ended up solving my issue by using the _compilation.createChildCompiler functionality. If you're interested, you can see how I do that here.

@dallas
Copy link

dallas commented Apr 27, 2016

Cool, thanks for that info, @jessepollak!

We actually ended up with a different solution using the exports-loader like so:

loader: 'exports-loader?module.exports.toString()!css-loader'

as advised in gajus/to-string-loader#2 (comment)

@machadoum
Copy link

Same problem as @kpdecker here. I have to build a static json (tojson-loader) that depends on a image path (file-loader).
I made this repository to explain the error: https://github.com/machadoum/webpack-loader-loader

Any idea?

@bebraw
Copy link
Contributor

bebraw commented Dec 25, 2016

Can you try against webpack 2?

@cvle
Copy link

cvle commented Jan 18, 2017

Hit on this on webpack 2.

@cvle
Copy link

cvle commented Feb 4, 2017

I quickly put together a version of val-loader that uses a child compiler based on the work done by Nathan Tran for css-in-js-loader.

See https://github.com/wikiwi/value-loader.

@webpack-bot
Copy link
Contributor

This issue had no activity for at least half a year.

It's subject to automatic issue closing if there is no activity in the next 15 days.

@webpack-bot
Copy link
Contributor

Issue was closed because of inactivity.

If you think this is still a valid issue, please file a new issue with additional information.

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

No branches or pull requests