Skip to content
This repository was archived by the owner on Oct 12, 2021. It is now read-only.
This repository was archived by the owner on Oct 12, 2021. It is now read-only.

packaging for Angular Universal #184

Description

@ivancamilov

I'm using the official guide for building an Angular Universal project using the CLI. However, the application won't run when importing ServiceWorkerModule. It gives this error:

/project/node_modules/@angular/service-worker/companion/module.js:1
(function (exports, require, module, __filename, __dirname) { import { NgModule } from '@angular/core';
                                                              ^^^^^^
SyntaxError: Unexpected token import
    at Object.exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:543:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.kEM4 (/project/dist-server/main.bundle.js:1:256573)
    at n (/project/dist-server/main.bundle.js:1:211)

From what I understand, this issue is caused because @angular/service-worker needs to be packaged using commonjs. Here are some official guidelines for packaging I found.

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