Greentube / localize-router

An implementation of routes localisation for Angular
MIT License
193 stars 93 forks source link

Angular 4 Universal project - problem with "Unexpected token import" #82

Closed qubiack closed 7 years ago

qubiack commented 7 years ago

Hi, I use your library, but it's impossible to build a project with this library for Angular 4 Universal server. It's look like a problem with you library export files - you can find more details about this problem hire: https://github.com/angular/angular-cli/issues/7200 especially in Toxicable commented on Sep 12.

What I finnally see is:

> ts-node src/server.ts

/home/xxxx/Projects/private/angular4-cli-seed/node_modules/localize-router/src/localize-router.config.js:1
(function (exports, require, module, __filename, __dirname) { import { Inject, OpaqueToken } from '@angular/core';
                                                              ^^^^^^

SyntaxError: Unexpected token import
    at createScript (vm.js:74:10)
    at Object.runInThisContext (vm.js:116:10)
    at Module._compile (module.js:588:28)
    at Module._extensions..js (module.js:635:10)
    at Object.require.extensions.(anonymous function) [as .js] (/home/xxxx/Projects/private/angular4-cli-seed/node_modules/ts-node/src/index.ts:384:14)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! angular4-cli-seed@0.0.0 start: `ts-node src/server.ts`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the angular4-cli-seed@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

--- EDIT Temporary I use this solution: https://stackoverflow.com/questions/46873887/unexpected-token-import-when-use-localize-router-in-angular-4-universal-app?noredirect=1

meeroslav commented 7 years ago

Thanks for bringing this up. I will look into it

umeshkumawat commented 7 years ago

Can this problem be solved using webpack-node-externals module?

I'm running an Angular 4 Universal project with it with no problems.

On Oct 24, 2017 8:59 PM, "Miroslav Jonaš" notifications@github.com wrote:

Thanks for bringing this up. I will look into it

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Greentube/localize-router/issues/82#issuecomment-339030520, or mute the thread https://github.com/notifications/unsubscribe-auth/AH7MPktv1j32yKrp5qnounzMCBgqlotyks5svgJWgaJpZM4QCBeZ .

qubiack commented 7 years ago

@umeshkumawat I think that Babel or recompile are only solutions for this issue.