-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(angular): official v9 ivy support (#201)
- Loading branch information
1 parent
cc6ced2
commit a5f2e62
Showing
28 changed files
with
378 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 2 additions & 9 deletions
11
packages/electron-angular/src/schematics/application/_files/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,7 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"sourceMap": true, | ||
"declaration": false, | ||
"moduleResolution": "node", | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"esModuleInterop": true, | ||
"target": "es5", | ||
"typeRoots": ["../../node_modules/@types"], | ||
"lib": ["es2017", "es2016", "es2015", "dom"] | ||
"types": ["node", "jest"] | ||
}, | ||
"include": ["src/index.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletions
140
packages/nativescript-angular/migrations/update-9-0-4/update-9-0-4.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import { | ||
chain, | ||
Rule, | ||
SchematicContext, | ||
Tree | ||
} from '@angular-devkit/schematics'; | ||
import { join } from 'path'; | ||
import * as fs from 'fs'; | ||
import { updateJsonInTree, createOrUpdate } from '@nrwl/workspace'; | ||
import { getJsonFromFile, updateJsonFile, output } from '@nstudio/xplat'; | ||
import { | ||
nsCoreVersion, | ||
terserWebpackVersion, | ||
nsNgScopedVersion, | ||
ngxTranslateVersion, | ||
nsDevWebpackVersion, | ||
typescriptVersion, | ||
angularVersion | ||
} from '../../src/utils/versions'; | ||
|
||
const ngDeps = { | ||
'@angular/animations': angularVersion, | ||
'@angular/common': angularVersion, | ||
'@angular/compiler': angularVersion, | ||
'@angular/core': angularVersion, | ||
'@angular/forms': angularVersion, | ||
'@angular/platform-browser': angularVersion, | ||
'@angular/platform-browser-dynamic': angularVersion, | ||
'@angular/router': angularVersion | ||
}; | ||
|
||
function updateNativeScriptApps(tree: Tree, context: SchematicContext) { | ||
const appsDir = tree.getDir('apps'); | ||
const appFolders = appsDir.subdirs; | ||
const cwd = process.cwd(); | ||
const webpackConfigPath = join( | ||
cwd, | ||
'node_modules/@nstudio/nativescript-angular/src/schematics/application/_files/webpack.config.js' | ||
); | ||
// console.log('webpackConfigPath:', webpackConfigPath); | ||
const webpackConfig = fs.readFileSync(webpackConfigPath, 'UTF-8'); | ||
const srcPackagePath = join( | ||
cwd, | ||
'node_modules/@nstudio/nativescript-angular/src/schematics/application/_files/src/package.json' | ||
); | ||
// console.log('webpackConfigPath:', webpackConfigPath); | ||
const srcPackage = fs.readFileSync(srcPackagePath, 'UTF-8'); | ||
const ngccConfigPath = join( | ||
cwd, | ||
'node_modules/@nstudio/nativescript-angular/src/schematics/application/_files/ngcc.config.js' | ||
); | ||
const ngccConfig = fs.readFileSync(ngccConfigPath, 'UTF-8'); | ||
|
||
const tsconfigTnsPath = join( | ||
cwd, | ||
'node_modules/@nstudio/nativescript-angular/src/schematics/application/_files/tsconfig.tns.json' | ||
); | ||
const tsconfigTns = fs.readFileSync(tsconfigTnsPath, 'UTF-8'); | ||
|
||
const appsNames = []; | ||
// update {N} apps and configs | ||
for (const dir of appFolders) { | ||
// console.log(dir); | ||
if ( | ||
dir.indexOf('nativescript-') === 0 || | ||
dir.indexOf('-nativescript') === 0 | ||
) { | ||
const appDir = `${appsDir.path}/${dir}`; | ||
// console.log('appDir:', appDir); | ||
appsNames.push(dir); | ||
|
||
createOrUpdate(tree, `${appDir}/webpack.config.js`, webpackConfig); | ||
createOrUpdate(tree, `${appDir}/src/package.json`, srcPackage); | ||
createOrUpdate(tree, `${appDir}/ngcc.config.js`, ngccConfig); | ||
createOrUpdate(tree, `${appDir}/tsconfig.tns.json`, tsconfigTns); | ||
|
||
// update {N} app deps | ||
const packagePath = `${appDir}/package.json`; | ||
const packageJson = getJsonFromFile(tree, packagePath); | ||
|
||
if (packageJson) { | ||
packageJson.dependencies = packageJson.dependencies || {}; | ||
packageJson.dependencies = { | ||
...packageJson.dependencies, | ||
...ngDeps, | ||
'@nativescript/angular': nsNgScopedVersion, | ||
'@nativescript/core': nsCoreVersion, | ||
'@ngx-translate/core': ngxTranslateVersion | ||
}; | ||
delete packageJson.dependencies['nativescript-angular']; | ||
delete packageJson.dependencies['tns-core-modules']; | ||
packageJson.devDependencies = packageJson.devDependencies || {}; | ||
packageJson.devDependencies = { | ||
...packageJson.devDependencies, | ||
'@angular/compiler-cli': angularVersion, | ||
'@ngtools/webpack': angularVersion, | ||
'nativescript-dev-webpack': nsDevWebpackVersion, | ||
'terser-webpack-plugin': terserWebpackVersion, | ||
'tns-platform-declarations': nsCoreVersion, | ||
typescript: typescriptVersion | ||
}; | ||
|
||
// console.log('path:',path); | ||
// console.log('packageJson overwrite:', JSON.stringify(packageJson)); | ||
tree = updateJsonFile(tree, packagePath, packageJson); | ||
} | ||
} | ||
output.log({ | ||
title: 'Migration Note:', | ||
bodyLines: [ | ||
`Please ensure you have the latest NativeScript cli installed: npm i -g nativescript`, | ||
`The following NativeScript apps have been updated to 9.0: ${appsNames}. The following files in those apps have been updated: webpack.config.js, src/package.json, ngcc.config.js and package.json. You may want to check the changeset to keep any customizations you may have made.`, | ||
`Please note that you may still need to update your project imports to @nativescript/angular instead of nativescript-angular.` | ||
] | ||
}); | ||
} | ||
return tree; | ||
} | ||
|
||
function updateRootPackage(tree: Tree, context: SchematicContext) { | ||
return updateJsonInTree('package.json', json => { | ||
json.scripts = json.scripts || {}; | ||
json.dependencies = json.dependencies || {}; | ||
json.dependencies = { | ||
...json.dependencies, | ||
...ngDeps, | ||
'@nativescript/angular': nsNgScopedVersion, | ||
'@ngx-translate/core': ngxTranslateVersion | ||
}; | ||
delete json.dependencies['nativescript-angular']; | ||
delete json.dependencies['tns-core-modules']; | ||
json.devDependencies = json.devDependencies || {}; | ||
|
||
return json; | ||
})(tree, context); | ||
} | ||
|
||
export default function(): Rule { | ||
return chain([updateNativeScriptApps, updateRootPackage]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
packages/nativescript-angular/src/schematics/application/_files/ngcc.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
module.exports = { | ||
packages: { | ||
'@nativescript/angular': { | ||
entryPoints: { | ||
'.': { | ||
override: { | ||
main: './index.js', | ||
typings: './index.d.ts' | ||
}, | ||
ignoreMissingDependencies: true | ||
} | ||
}, | ||
ignorableDeepImportMatchers: [ | ||
/zone.js\//, | ||
/tns-core-modules\//, | ||
/@nativescript\/core\// | ||
] | ||
}, | ||
'nativescript-datetimepicker': { | ||
entryPoints: { | ||
'.': { | ||
override: { | ||
main: './index.js', | ||
typings: './index.d.ts' | ||
}, | ||
ignoreMissingDependencies: true | ||
}, | ||
angular: { | ||
override: { | ||
main: './index.js', | ||
typings: './index.d.ts' | ||
}, | ||
ignoreMissingDependencies: true | ||
} | ||
}, | ||
ignorableDeepImportMatchers: [ | ||
/tns-core-modules\//, | ||
/@nativescript\/core\//, | ||
/@nativescript\/angular\// | ||
] | ||
}, | ||
'nativescript-ui-sidedrawer': { | ||
entryPoints: { | ||
angular: { | ||
override: { | ||
main: './side-drawer-directives.js', | ||
typings: './side-drawer-directives.d.ts' | ||
}, | ||
ignoreMissingDependencies: true | ||
} | ||
}, | ||
ignorableDeepImportMatchers: [ | ||
/tns-core-modules\//, | ||
/@nativescript\/core\//, | ||
/@nativescript\/angular\// | ||
] | ||
}, | ||
'nativescript-ui-listview': { | ||
entryPoints: { | ||
angular: { | ||
override: { | ||
main: './listview-directives.js', | ||
typings: './listview-directives.d.ts' | ||
}, | ||
ignoreMissingDependencies: true | ||
} | ||
}, | ||
ignorableDeepImportMatchers: [ | ||
/tns-core-modules\//, | ||
/@nativescript\/core\//, | ||
/@nativescript\/angular\// | ||
] | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
...ivescript-angular/src/schematics/application/_files/src/app.module.ngfactory.d.ts__tmpl__
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ platforms/ | |
*.js.map | ||
*.js | ||
!webpack.config.js | ||
!ngcc.config.js | ||
|
||
# Logs | ||
logs | ||
|
Oops, something went wrong.