Skip to content

@ngtools/webpack plugin error: Unexpected token { #5364

@GeorgeKnap

Description

@GeorgeKnap

OS?

Windows 10

Versions.

"dependencies": {
    "@angular/common": "4.0.0-rc.2",
    "@angular/compiler": "4.0.0-rc.2",
    "@angular/compiler-cli": "4.0.0-rc.2",
    "@angular/core": "4.0.0-rc.2",
    "@angular/forms": "4.0.0-rc.2",
    "@angular/http": "4.0.0-rc.2",
    "@angular/platform-browser": "4.0.0-rc.2",
    "@angular/platform-browser-dynamic": "4.0.0-rc.2",
    "@angular/router": "4.0.0-rc.2",
    "core-js": "2.4.1",    
"hammerjs": "2.0.8",
    "reflect-metadata": "0.1.10",
    "rxjs": "5.2.0",
    "zone.js": "0.7.8",
...
  },
  "devDependencies": {
    ...
    "@ngtools/webpack": "1.2.12",
    "typescript": "2.2.1",
    "webpack": "2.2.1",
    "webpack-dev-server": "2.4.1",
    "webpack-merge": "4.0.0"
  },

Repro steps.

Not using the CLI seed but the webpack introduction.
the webpack npm task "webpack:dev-host": "webpack-dev-server --inline --progress --port 8080", crash with following error

The log given by the failure.

C:\Development\templates\Angular\AG2\src\AG2.Web> cmd.exe /c npm run webpack:dev-host --color=always
> ag2@1.0.0 webpack:dev-host C:\Development\templates\Angular\AG2\src\AG2.Web
> webpack-dev-server --inline --progress --port 8080
C:\Development\templates\Angular\AG2\src\AG2.Web\node_modules\@ngtools\webpack\src\plugin.js:270
                const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
                      ^
SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:404:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (C:\Development\templates\Angular\AG2\src\AG2.Web\node_modules\@ngtools\webpack\src\index.js:6:10)
    at Module._compile (module.js:397:26)
    at Object.Module._extensions..js (module.js:404:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (C:\Development\templates\Angular\AG2\src\AG2.Web\config\webpack.common.js:5:22)
    at Module._compile (module.js:397:26)

webpack config:

var ngToolsWebpack = require('@ngtools/webpack');
module: {
        rules: [
            {
                test: /\.ts$/,
                loader: '@ngtools/webpack',
                exclude: helpers.root('node_modules')
            },
            ...
        ]
    },
 plugins: [
        new ngToolsWebpack.AotPlugin({
            tsConfigPath: helpers.root('tsconfig.json'),
            entryModule: helpers.root('app/app.module#AppModule'),
            mainPath: helpers.root('app/main.ts')
        }),

    ...
    ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions