Open ma2ciek opened 7 years ago
Although it has warning in webpack 2.2.0, but is still worked in my project.
It turned out that the bug (or feature) was somewhere else.
Webpack parser runs "call fn" callback only when fn is not defined in the code (I'm not sure why). So when I have
const t = this.t;
t()
the parser doesn't see t
invocation.
I have to use t()
function later to provide multi-language support and to be able to transform this string later based on that string and additional words (translated string is used as a template).
I'm with this problem too
Either do I, anyone knows how to fix it?
I had to use acorn to be able to create translation service https://github.com/ckeditor/ckeditor5-dev/blob/master/packages/ckeditor5-dev-utils/lib/translations/translationservice.js, but it would be much nicer if the webpack could handle it by itself.
@ma2ciek @d3viant0ne noticed it had been a couple weeks since this was last commented on, was hoping to see if there was some kind of resolution? Thanks for the help!
I had to implement my own solution with usage of the Acorn parser,
@alphapilgrim - There is a 1.0.0-beta.0
build on npm that will solve that particular issue. Keep in mind there is going to be churn on that beta dist-tag for a few weeks.
Webpack parser runs "call fn" callback only when fn is not defined in the code (I'm not sure why).
@ma2ciek looks like it's a current implementation of the webpack's Parser. See: https://github.com/webpack/webpack/blob/master/lib/Parser.js#L257 https://github.com/webpack/webpack/blob/master/lib/Parser.js#L1100
I'm not sure why you want to replace the calls of defined functions, but looks like to affect them you have to register another callback for the evaluate defined Identifier ${functionName}
event and return an evaluated expression (instance of BasicEvaluatedExpression).
Smthing like this:
const BasicEvaluatedExpression = require('webpack/lib/BasicEvaluatedExpression');
// ...
parser.plugin(`evaluate defined Identifier ${name}`, function (expr) {
return new BasicEvaluatedExpression().setIdentifier(expr.name).setRange(expr.range);
});
I'm using webpack@2.2.0 and wanted to take a look at this plugin while working on the https://github.com/ckeditor/ckeditor5/issues/387, but I got into few troubles.
compiler.parser.plugin
is deprecated now. So I changed this line into something like this:But unfortunately it seems to be not working now... Could you provide some info how to fix it?
Regards, Maciek