Closed kentcdodds closed 7 years ago
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.
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... :-/
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.
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?
This syntax seems to work:
loader: 'imports-loader', options: { define: ">false", module: ">false" }
I'm using this and it still working for me:
{
test: require.resolve('foo'),
use: ['imports-loader?this=>window', 'exports-loader?foo']
}
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: https://github.com/webpack/webpack/issues/3017
@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?
sorry, you're right, it's unrelated.
I've resolved my issue using a built-in option:
module: {
rules: [
{ parser: { amd: false } }
]
}
Does this loader support Webpack 2? If so, how would you specify the options with the new
rules
API?For example. I have this:
I was thinking:
But I'm unsure, and it seems odd...