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

Webpack 2? #38

Closed
kentcdodds opened this issue Jan 25, 2017 · 10 comments
Closed

Webpack 2? #38

kentcdodds opened this issue Jan 25, 2017 · 10 comments

Comments

@kentcdodds
Copy link

Does this loader support Webpack 2? If so, how would you specify the options with the new rules API?

For example. I have this:

{
    test: /globalize/,
    loader: 'imports?define=>false',
},

I was thinking:

{
    test: /globalize/,
    use: [{ loader: 'imports-loader', options: { 'define=>false': '' } }],
}

But I'm unsure, and it seems odd...

@TheLarkInn
Copy link

That actually might be something that works. It's like you mentioned the => which is the unconventional piece thats parsed here.

If you didn't have to use the `=> syntax, how would you imagine it working.

@kentcdodds
Copy link
Author

Yeah, honestly, the whole thing's kinda whacky... I tried the above code and that didn't work. Not sure how to make it work properly so I'm using the old query string API for now... :-/

@TheLarkInn
Copy link

I mean, it looks like these symbols (first time even looking at this loader), to expand into expressions. Would it make it undesirable to just pick the type of expression needed.

@kentcdodds
Copy link
Author

Yeah, honestly, I'm not a huge fan of the syntax as it is... It's pretty overloaded (just look at the table). I would rather something simpler, like:

Option value Equals
angular: 'require("angular")' var angular = require("angular");
$: 'require("jquery") var $ = require("jquery");
define: 'false' var define = false;
config: '{size:50}' var config = {size:50};
'this': 'window' (function () { ... }).call(window);

Notice that the only special case is the last one because that's kinda hard to represent in any other way... Thoughts?

@djedje72
Copy link

djedje72 commented Jan 26, 2017

This syntax seems to work:

loader: 'imports-loader', options: { define: ">false", module: ">false" }

@ahmedelgabri
Copy link

I'm using this and it still working for me:

{ 
  test: require.resolve('foo'), 
  use: ['imports-loader?this=>window', 'exports-loader?foo'] 
}

@Vanuan
Copy link

Vanuan commented Mar 11, 2017

This is what is printed for me:

loaderUtils.parseQuery() received a non-string value which can be problematic, see https://github.com/webpack/loader-utils/issues/56
parseQuery() will be replaced with getOptions() in the next major version of loader-utils.

And it doesn't work, I still see "true" instead of typeof define == 'function'

This is the the context I'm coming from: webpack/webpack#3017

@joshwiens
Copy link
Member

joshwiens commented Mar 11, 2017

@Vanuan - That is a deprecation warning from loader-utils

See: 7129a27 for exactly what was changed to accomodate the change from loader-utils

As to your specific issue, I'd need to see exactly what you are trying to do. Got a project I can go dig around in?

@Vanuan
Copy link

Vanuan commented Mar 12, 2017

sorry, you're right, it's unrelated.

@Vanuan
Copy link

Vanuan commented Mar 12, 2017

I've resolved my issue using a built-in option:

module: {
  rules: [
    { parser: { amd: false } }
  ]
}

mlazowik added a commit to mlazowik/imports-loader that referenced this issue Apr 29, 2017
@michael-ciniawsky michael-ciniawsky added this to the v1.0.0 milestone Apr 29, 2017
@joshwiens joshwiens removed their assignment Aug 18, 2017
@michael-ciniawsky michael-ciniawsky removed this from the 1.0.0 milestone Feb 20, 2018
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

7 participants