@@ -4,7 +4,7 @@ import parseVersionString from 'parse-version-string';
4
4
import { Observable } from 'rxjs' ;
5
5
import { spawn } from 'child_process' ;
6
6
import * as path from 'path' ;
7
- import { existsSync , readFileSync , writeFileSync , mkdirSync } from 'fs' ;
7
+ import { existsSync , readFileSync , writeFileSync , unlinkSync } from 'fs' ;
8
8
import { Tree , serializeJson } from '@nx/devkit' ;
9
9
10
10
interface ISemVer {
@@ -88,6 +88,25 @@ export default async function (tree: Tree, schema: Schema) {
88
88
await new Promise < void > ( ( resolve , reject ) => {
89
89
// console.log(options.args);
90
90
let cnt = 0 ;
91
+ const cleanPackage = ( ) => {
92
+ // helps remove unwanted properties which may be added by other tooling
93
+ const p = publishPackages [ cnt ] ;
94
+ const packageJsonPath = path . resolve ( workspaceDir , 'dist' , 'packages' , p , 'package.json' ) ;
95
+ let packageJson : any = readFileSync ( packageJsonPath , { encoding : 'utf-8' } ) ;
96
+ if ( packageJson ) {
97
+ packageJson = jsonParse ( packageJson ) ;
98
+ // we don't need module or type properties at the moment
99
+ delete packageJson [ 'module' ] ;
100
+ delete packageJson [ 'type' ] ;
101
+ writeFileSync ( packageJsonPath , serializeJson ( packageJson ) ) ;
102
+
103
+ const angularNpmIgnorePath = path . resolve ( workspaceDir , 'dist' , 'packages' , p , 'angular' , '.npmignore' ) ;
104
+ // remove .npmignore as we don't need it in angular folder if found
105
+ if ( existsSync ( angularNpmIgnorePath ) ) {
106
+ unlinkSync ( angularNpmIgnorePath ) ;
107
+ }
108
+ }
109
+ } ;
91
110
const buildPackage = ( ) => {
92
111
const p = publishPackages [ cnt ] ;
93
112
@@ -105,6 +124,8 @@ export default async function (tree: Tree, schema: Schema) {
105
124
child . on ( 'close' , ( res ) => {
106
125
console . log ( 'build finished with code:' , res ) ;
107
126
child . kill ( ) ;
127
+ // cleanup anything with the package not needed
128
+ cleanPackage ( ) ;
108
129
cnt ++ ;
109
130
if ( cnt === publishPackages . length ) {
110
131
console . log ( `✅ Successfully built ${ packageVersions . map ( ( p ) => `${ p . name } :${ p . version } ` ) . join ( ',' ) } ` ) ;
0 commit comments