jawache / angularjs-migration

45 stars 56 forks source link

Angular 9 - Unable to downgradeInjectable #3

Closed akhilesh-bangalore closed 4 years ago

akhilesh-bangalore commented 4 years ago

Hi,

I was going over your lectures one step at a time and at step 7, I see the below error when running in Angular 9 + AngularJS 1.7.9 hybrid. Can you please help?


bundle.js:36704 Uncaught Error: Can't resolve all parameters for ApplicationModule: (?).
    at syntaxError (bundle.js:36704)
    at CompileMetadataResolver._getDependenciesMetadata (bundle.js:56733)
    at CompileMetadataResolver._getTypeMetadata (bundle.js:56625)
    at CompileMetadataResolver.getNgModuleMetadata (bundle.js:56493)
    at CompileMetadataResolver.getNgModuleSummary (bundle.js:56300)
    at bundle.js:56414
    at Array.forEach (<anonymous>)
    at CompileMetadataResolver.getNgModuleMetadata (bundle.js:56402)
    at CompileMetadataResolver.getNgModuleSummary (bundle.js:56300)
    at bundle.js:56387```
akhilesh-bangalore commented 4 years ago

I have resolved this by moving the import './polyfills.ts' statement from main.ts to webpack.config.js.

const path = require('path');
const webpack = require('webpack');

module.exports = {
    entry: ["./src/app/polyfills.ts", "./src/app/main.ts"],
    output: {
        filename: "bundle.js",
        path: path.join(__dirname, "src", "dist")
    },
    resolve: {
        // Add '.ts' and '.tsx' as a resolvable extension.
        extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js"]
    },
    module: {
        loaders: [
            // all files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'
            { test: /\.tsx?$/, loader: "ts-loader" }
        ]
    },
    plugins: [
        new webpack.ContextReplacementPlugin(
            // if you have anymore problems tweet me at @gdi2290
            // The (\\|\/) piece accounts for path separators for Windows and MacOS
            /(.+)?angular(\\|\/)core(.+)?/,
            path.join(__dirname, 'src'), // location of your src
            {} // a map of your routes 
        )
    ]    
};