This project is generated with yo angular generator version 0.15.1. However this does not matter, the instructions in this repo should work with any legacy angular 1 project.
Look at the commit history to understand the steps on how this hijacking was performed on a regular angular 1 repo. Ignore the gulp commit since I scraped that and went with webpack. Note that the server should still be ran with grunt serve
( the whole point is for this to work nonintrusively with legacy tools ), however if running webpack --watch
at the same time, all typescript files referenced by app.ts will be bundled in a javascript file and made available to the grunt side to be served.
Run grunt
for building and grunt serve
for preview.
Run webpack --watch
to have webpack watch for typescript file changes. Please follow the hijacking instructions before, so this can work.
You should be able to use these instructions on top of any legacy angular 1 project.
This is the webpack configuration file
This directory contains the angular 1 to 2 transitional framework.
This will become the entry point for the app.
If ng-app is not used, remove the bootstraping code for your current app.
This is the root of the hijacking mechanism. Your old js app becomes a dependency for your new TypeScript app. Anything from the old JS app is brought over, and anything new written in TypeScript can work with the old code.
This is a very non intrusive strategy.
This is a test component. If things work well, adding anywhere in your old app should render this component, which is written in TypeScript using syntax very similar to angular 2.
Webpack will also need to be installed globally.
There are various paths in the files that need to be updated based on the choices made on where they should live in the new project.
The webpack.config.js declares an output file destination. All your type script code will be compiled here. Including this file in your index.html AFTER your legacy javascript app angular module declaration, will allow the typescript app.ts to take over bootstraping while still including your legacy code.
Please note that the TypeScript files can be debugged directly in Chrome Dev Tools due to the sourcemap features included in this example. The typescript files can be found under Chrome Dev Tools > Sources > webpack://
😅
npm install redux redux-thunk ng-redux --save
npm install typings -g
typings install -SG dt~redux-thunk