From 20e3db6430f58183eb60b54c320c0f0337739ccc Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Tue, 5 Dec 2017 12:09:32 +0100 Subject: [PATCH] fix(*): package code is bundles twice from `src` and `es5` file Remove `JavaScript` from `src` folder as this is not required by the consumers and in some cases with `Angular 4.x.x` and `@ngtools/webpack` it causes the `src` to be bundled togather with the `FESM`. With Angular 4 and Webpack the javascript in `src` is being used rather than the FESM. Relates: #184 --- build/builder.ts | 1 + build/tasks.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/build/builder.ts b/build/builder.ts index ed886b0d76..8736d44dc2 100644 --- a/build/builder.ts +++ b/build/builder.ts @@ -9,6 +9,7 @@ export default createBuilder([ ['Creating UMD Bundles', tasks.createUmdBundles], ['Renaming package entry files', tasks.renamePackageEntryFiles], ['Cleaning TypeScript files', tasks.cleanTypeScriptFiles], + ['Cleaning JavaScript files', tasks.cleanJavaScriptFiles], ['Removing remaining sourcemap files', tasks.removeRemainingSourceMapFiles], ['Copying type definition files', tasks.copyTypeDefinitionFiles], ['Minifying UMD bundles', tasks.minifyUmdBundles], diff --git a/build/tasks.ts b/build/tasks.ts index 354dc61633..55a2cde70b 100644 --- a/build/tasks.ts +++ b/build/tasks.ts @@ -122,6 +122,21 @@ export async function cleanTypeScriptFiles(config: Config) { await mapAsync(filesToRemove, util.remove); } +/** + * Removes any leftover Javascript files from previous compilation steps, + * leaving the bundles and FESM in place + */ +export async function cleanJavaScriptFiles(config: Config) { + const jsFilesGlob = './dist/packages/**/*.js'; + const jsExcludeFilesFlob = './dist/packages/(bundles|@ngrx)/**/*.js'; + const filesToRemove = await util.getListOfFiles( + jsFilesGlob, + jsExcludeFilesFlob + ); + + await mapAsync(filesToRemove, util.remove); +} + /** * Renames the index files in each package to the name * of the package.