File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
packages/angular-html-parser Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 1919 "license" : " MIT" ,
2020 "scripts" : {
2121 "prepublish" : " yarn run build" ,
22- "build" : " yarn clean && yarn build-lib" ,
22+ "build" : " yarn clean && yarn build-lib && yarn codemod " ,
2323 "clean" : " del-cli ./lib" ,
2424 "build-lib" : " tsc -p tsconfig.build.json" ,
25+ "codemod" : " node ./node_modules/jscodeshift/bin/jscodeshift.js -t postbuild-codemod.ts lib --extensions=js,ts --parser=ts" ,
2526 "test" : " ts-node --project tsconfig.test.json -r tsconfig-paths/register node_modules/jasmine/bin/jasmine.js ../compiler/test/ml_parser/*_spec.ts ./test/*_spec.ts" ,
2627 "release" : " standard-version"
2728 },
Original file line number Diff line number Diff line change 1+ import { API , FileInfo } from 'jscodeshift' ;
2+
3+ export default function transformer ( file : FileInfo , api : API ) {
4+ const j = api . jscodeshift ;
5+
6+ const ast = j ( file . source ) ;
7+
8+ ast . find ( j . ImportDeclaration ) . forEach ( ( { node} ) => {
9+ const source = node . source . value as string ;
10+ if ( ! source . endsWith ( '.js' ) ) {
11+ node . source . value = source + '.js' ;
12+ }
13+ } ) ;
14+
15+ ast . find ( j . TSTypeAliasDeclaration ) . forEach ( ( { node} ) => {
16+ if ( node . id . name === 'Node' && node . typeAnnotation . type === 'TSUnionType' ) {
17+ node . typeAnnotation . types = node . typeAnnotation . types . filter (
18+ ( type ) =>
19+ type . type === 'TSTypeReference' &&
20+ type . typeName . type === 'Identifier' &&
21+ type . typeName . name !== 'Expansion' &&
22+ type . typeName . name !== 'ExpansionCase'
23+ ) ;
24+ }
25+ } ) ;
26+
27+ return ast . toSource ( ) ;
28+ }
You can’t perform that action at this time.
0 commit comments