webpack-extract-translation-keys-plugin
Advanced tools
Comparing version 3.0.0 to 4.0.0
@@ -0,0 +0,0 @@ /*! |
28
index.js
@@ -43,11 +43,16 @@ /*! | ||
compiler.plugin('compilation', function(compilation, params) { | ||
compiler.hooks.compilation.tap('WebpackExtractTranslationKeys', function(compilation) { | ||
compilation.dependencyFactories.set(ConstDependency, new NullFactory()); | ||
compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template()); | ||
}); | ||
params.normalModuleFactory.plugin('parser', function(parser) { | ||
compiler.hooks.normalModuleFactory.tap('WebpackExtractTranslationKeys', function(factory) { | ||
parser.plugin('call ' + functionName, function(expr) { | ||
factory.hooks.parser.for('javascript/auto').tap('WebpackExtractTranslationKeys', function(parser) { | ||
parser.hooks.call.for(functionName).tap('WebpackExtractTranslationKeys', function(expr) { | ||
var key; | ||
if (!expr.arguments.length) { | ||
this.state.module.errors.push( | ||
new NoTranslationKeyError(this.state.module, expr) | ||
parser.state.module.errors.push( | ||
new NoTranslationKeyError(parser.state.module, expr) | ||
); | ||
@@ -57,6 +62,6 @@ return false; | ||
key = this.evaluateExpression(expr.arguments[0]); | ||
key = parser.evaluateExpression(expr.arguments[0]); | ||
if (!key.isString()) { | ||
this.state.module.errors.push( | ||
new DynamicTranslationKeyError(this.state.module, expr) | ||
parser.state.module.errors.push( | ||
new DynamicTranslationKeyError(parser.state.module, expr) | ||
); | ||
@@ -81,3 +86,3 @@ return false; | ||
dep.loc = expr.arguments[0].loc; | ||
this.state.current.addDependency(dep); | ||
parser.state.current.addDependency(dep); | ||
} | ||
@@ -88,8 +93,5 @@ | ||
}); | ||
compilation.dependencyFactories.set(ConstDependency, new NullFactory()); | ||
compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template()); | ||
}); | ||
compiler.plugin('done', function() { | ||
compiler.hooks.done.tap('WebpackExtractTranslationKeys', function() { | ||
this.done(this.keys); | ||
@@ -96,0 +98,0 @@ if (this.output) { |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ /*! |
{ | ||
"name": "webpack-extract-translation-keys-plugin", | ||
"version": "3.0.0", | ||
"version": "4.0.0", | ||
"description": "Webpack plugin to extract list of used translation keys from included modules.", | ||
"main": "index.js", | ||
"scripts": { | ||
"prepublish": "npm run lint && npm test", | ||
"prepublishOnly": "npm run lint && npm test", | ||
"lint": "eslint .", | ||
"test": "mocha --harmony test", | ||
"tdd": "mocha --harmony --watch test" | ||
"test": "mocha test", | ||
"tdd": "mocha --watch test" | ||
}, | ||
@@ -31,7 +31,7 @@ "files": [ | ||
"bondjs": "^1.2.2", | ||
"eslint": "^0.21.2", | ||
"mocha": "^2.2.5", | ||
"eslint": "^5.2.0", | ||
"mocha": "^5.2.0", | ||
"tranzlate": "1.2.0", | ||
"webpack": "2.1.0-beta.25" | ||
"webpack": "^4.16.2" | ||
} | ||
} |
@@ -9,2 +9,6 @@ # Webpack Extract Translation Keys Plugin | ||
## Changelog | ||
* **4.0.0**: Compatibility with Webpack 4 | ||
## Usage | ||
@@ -11,0 +15,0 @@ |
12246
150
145