Skip to content

Commit f143cb6

Browse files
clydinBrocco
authored andcommitted
refactor(@angular/cli): use memory FS for i18n extraction (#6306)
1 parent b4abe6d commit f143cb6

File tree

3 files changed

+14
-22
lines changed

3 files changed

+14
-22
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"loader-utils": "^1.0.2",
6969
"lodash": "^4.11.1",
7070
"magic-string": "^0.19.0",
71+
"memory-fs": "^0.4.1",
7172
"minimatch": "^3.0.3",
7273
"node-modules-path": "^1.0.0",
7374
"nopt": "^4.0.1",

packages/@angular/cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"less": "^2.7.2",
5454
"less-loader": "^4.0.2",
5555
"lodash": "^4.11.1",
56+
"memory-fs": "^0.4.1",
5657
"minimatch": "^3.0.3",
5758
"node-modules-path": "^1.0.0",
5859
"nopt": "^4.0.1",
Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
11
import * as webpack from 'webpack';
2-
import * as path from 'path';
3-
import * as rimraf from 'rimraf';
2+
import { XI18nWebpackConfig } from '../models/webpack-xi18n-config';
3+
import { getAppFromConfig } from '../utilities/app-utils';
44

55
const Task = require('../ember-cli/lib/models/task');
6+
const MemoryFS = require('memory-fs');
67

7-
import {XI18nWebpackConfig} from '../models/webpack-xi18n-config';
8-
import {getAppFromConfig} from '../utilities/app-utils';
98

109
export const Extracti18nTask = Task.extend({
1110
run: function (runTaskOptions: any) {
12-
13-
const project = this.project;
14-
1511
const appConfig = getAppFromConfig(runTaskOptions.app);
1612

17-
const buildDir = '.tmp';
18-
const genDir = runTaskOptions.outputPath || appConfig.root;
19-
2013
const config = new XI18nWebpackConfig({
21-
genDir,
22-
buildDir,
14+
genDir: runTaskOptions.outputPath || appConfig.root,
15+
buildDir: '.tmp',
2316
i18nFormat: runTaskOptions.i18nFormat,
2417
locale: runTaskOptions.locale,
2518
outFile: runTaskOptions.outFile,
@@ -29,6 +22,7 @@ export const Extracti18nTask = Task.extend({
2922
}, appConfig).buildConfig();
3023

3124
const webpackCompiler = webpack(config);
25+
webpackCompiler.outputFileSystem = new MemoryFS();
3226

3327
return new Promise((resolve, reject) => {
3428
const callback: webpack.compiler.CompilerCallback = (err, stats) => {
@@ -45,15 +39,11 @@ export const Extracti18nTask = Task.extend({
4539

4640
webpackCompiler.run(callback);
4741
})
48-
.then(() => {
49-
// Deletes temporary build folder
50-
rimraf.sync(path.resolve(project.root, buildDir));
51-
})
52-
.catch((err: Error) => {
53-
if (err) {
54-
this.ui.writeError('\nAn error occured during the i18n extraction:\n'
55-
+ ((err && err.stack) || err));
56-
}
57-
});
42+
.catch((err: Error) => {
43+
if (err) {
44+
this.ui.writeError('\nAn error occured during the i18n extraction:\n'
45+
+ ((err && err.stack) || err));
46+
}
47+
});
5848
}
5949
});

0 commit comments

Comments
 (0)