Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit 21ed803

Browse files
committed
refactor(webpack): use incremental build
1 parent 683d4b2 commit 21ed803

File tree

7 files changed

+153
-160
lines changed

7 files changed

+153
-160
lines changed

config/webpack.config.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,23 @@ function getEntryPoint() {
99
if (process.env.IONIC_ENV === 'prod') {
1010
return '{{TMP}}/app/main.prod.js';
1111
}
12-
return '{{SRC}}/app/main.dev.ts';
12+
return '{{TMP}}/app/main.dev.js';
1313
}
1414

1515
module.exports = {
16-
devtool: 'cheap-module-source-map',
16+
devtool: 'source-map',
1717
entry: getEntryPoint(),
1818
output: {
1919
path: '{{BUILD}}',
2020
filename: 'main.js'
2121
},
2222

2323
resolve: {
24-
//modules: [path.resolve(__dirname, 'src'), 'node_modules'],
25-
extensions: ['.js', '.ts', '.json']
24+
extensions: ['.js', '.json']
2625
},
2726

2827
module: {
2928
loaders: [
30-
{
31-
test: /\.(ts|js)$/,
32-
loader: path.resolve(path.join(__dirname, '..', 'dist', 'loaders', 'ionic-loader.js'))
33-
},
3429
{
3530
test: /\.json$/,
3631
loader: 'json'

src/copy.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { BuildError, Logger } from './util/logger';
33
import { emit, EventType } from './util/events';
44
import { fillConfigDefaults, generateContext, getUserConfigFile, replacePathVars } from './util/config';
55
import * as fs from 'fs-extra';
6-
import * as path from 'path';
7-
6+
import { join as pathJoin, resolve as pathResolve, sep as pathSep } from 'path';
87

98
export function copy(context?: BuildContext, configFile?: string) {
109
context = generateContext(context);
@@ -46,7 +45,7 @@ export function copyUpdate(event: string, filePath: string, context: BuildContex
4645

4746
} else if (event === 'unlink' || event === 'unlinkDir') {
4847
return new Promise((resolve, reject) => {
49-
const destFile = path.join(context.rootDir, filePath);
48+
const destFile = pathJoin(context.rootDir, filePath);
5049
fs.remove(destFile, (err) => {
5150
if (err) {
5251
reject(new BuildError(err));
@@ -86,23 +85,23 @@ export function findFileCopyOptions(context: BuildContext, copyConfig: CopyConfi
8685
return copyOptions;
8786
}
8887

89-
filePath = path.join(context.rootDir, filePath);
88+
filePath = pathJoin(context.rootDir, filePath);
9089

91-
const filePathSegments = filePath.split(path.sep);
90+
const filePathSegments = filePath.split(pathSep);
9291
let srcPath: string;
9392
let srcLookupPath: string;
9493
let destCopyOption: string;
9594
let destPath: string;
9695

9796
while (filePathSegments.length > 1) {
98-
srcPath = filePathSegments.join(path.sep);
97+
srcPath = filePathSegments.join(pathSep);
9998

10099

101100
for (var i = 0; i < copyConfig.include.length; i++) {
102-
srcLookupPath = path.resolve(replacePathVars(context, copyConfig.include[i].src));
101+
srcLookupPath = pathResolve(replacePathVars(context, copyConfig.include[i].src));
103102

104103
if (srcPath === srcLookupPath) {
105-
destCopyOption = path.resolve(replacePathVars(context, copyConfig.include[i].dest));
104+
destCopyOption = pathResolve(replacePathVars(context, copyConfig.include[i].dest));
106105
destPath = filePath.replace(srcLookupPath, destCopyOption);
107106

108107
copyOptions.push({
@@ -126,8 +125,8 @@ export function findFileCopyOptions(context: BuildContext, copyConfig: CopyConfi
126125

127126
function copySrcToDest(context: BuildContext, src: string, dest: string, filter: any, clobber: boolean): Promise<string> {
128127
return new Promise((resolve, reject) => {
129-
src = path.resolve(replacePathVars(context, src));
130-
dest = path.resolve(replacePathVars(context, dest));
128+
src = pathResolve(replacePathVars(context, src));
129+
dest = pathResolve(replacePathVars(context, dest));
131130

132131
const opts = {
133132
filter: filter,

src/loaders/ionic-loader.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/util/helpers.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ import { outputJson, readFile, readJsonSync, writeFile } from 'fs-extra';
22
import { BuildError, Logger } from './logger';
33
import { join } from 'path';
44
import { tmpdir } from 'os';
5-
import { TsFiles } from './interfaces';
6-
7-
let tsFiles: TsFiles;
85

96
export const objectAssign = (Object.assign) ? Object.assign : function (target: any, source: any) {
107
const output = Object(target);
@@ -92,12 +89,3 @@ export function getModulePathsCache(): string[] {
9289
}
9390
return modulePaths;
9491
}
95-
96-
97-
export function cacheTranspiledTsFiles(inTsFiles: TsFiles) {
98-
tsFiles = inTsFiles;
99-
}
100-
101-
export function getCachedTranspiledTsFiles() {
102-
return tsFiles;
103-
}

src/util/in-memory-file-system.ts

Lines changed: 0 additions & 51 deletions
This file was deleted.

src/util/interfaces.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export interface BuildContext {
99
moduleFiles?: string[];
1010
isProd?: boolean;
1111
isWatch?: boolean;
12+
isUpdate?: boolean;
13+
fileChanged?: string;
1214
bundler?: string;
1315
useTranspileCache?: boolean;
1416
useBundleCache?: boolean;

0 commit comments

Comments
 (0)