Skip to content

refactor(@angular/cli): use memory FS for i18n extraction #6306

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

Merged
merged 1 commit into from May 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"loader-utils": "^1.0.2",
"lodash": "^4.11.1",
"magic-string": "^0.19.0",
"memory-fs": "^0.4.1",
"minimatch": "^3.0.3",
"node-modules-path": "^1.0.0",
"nopt": "^4.0.1",
Expand Down
1 change: 1 addition & 0 deletions packages/@angular/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"less": "^2.7.2",
"less-loader": "^4.0.2",
"lodash": "^4.11.1",
"memory-fs": "^0.4.1",
"minimatch": "^3.0.3",
"node-modules-path": "^1.0.0",
"nopt": "^4.0.1",
Expand Down
34 changes: 12 additions & 22 deletions packages/@angular/cli/tasks/extract-i18n.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
import * as webpack from 'webpack';
import * as path from 'path';
import * as rimraf from 'rimraf';
import { XI18nWebpackConfig } from '../models/webpack-xi18n-config';
import { getAppFromConfig } from '../utilities/app-utils';

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

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

export const Extracti18nTask = Task.extend({
run: function (runTaskOptions: any) {

const project = this.project;

const appConfig = getAppFromConfig(runTaskOptions.app);

const buildDir = '.tmp';
const genDir = runTaskOptions.outputPath || appConfig.root;

const config = new XI18nWebpackConfig({
genDir,
buildDir,
genDir: runTaskOptions.outputPath || appConfig.root,
buildDir: '.tmp',
i18nFormat: runTaskOptions.i18nFormat,
locale: runTaskOptions.locale,
outFile: runTaskOptions.outFile,
Expand All @@ -29,6 +22,7 @@ export const Extracti18nTask = Task.extend({
}, appConfig).buildConfig();

const webpackCompiler = webpack(config);
webpackCompiler.outputFileSystem = new MemoryFS();

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

webpackCompiler.run(callback);
})
.then(() => {
// Deletes temporary build folder
rimraf.sync(path.resolve(project.root, buildDir));
})
.catch((err: Error) => {
if (err) {
this.ui.writeError('\nAn error occured during the i18n extraction:\n'
+ ((err && err.stack) || err));
}
});
.catch((err: Error) => {
if (err) {
this.ui.writeError('\nAn error occured during the i18n extraction:\n'
+ ((err && err.stack) || err));
}
});
}
});