Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

webpack's resolve.alias doesn't seem to work for 3rd party modules #79

Closed
bbottema opened this issue May 20, 2016 · 5 comments
Closed

Comments

@bbottema
Copy link
Contributor

I'm trying to make npm ng2-prism work with this seed, but it has an issue importing angular2/http, which as we know have been rescoped into @angular.

However, I would have thought that the aliases in webpack's config would solve these, but for some reason it's not picking up the alias.

vendor.ts (this is the only file I modified in the seed project)

// Angular 2
import '@angular/platform-browser-dynamic';
import '@angular/platform-browser';
import '@angular/core';
import '@angular/http';
import '@angular/router-deprecated';

import 'ng2-prism';

The import in ng2-prism's source code is straightforward (codeblock.component.d.ts:1:66):

import { AfterViewChecked, AfterContentChecked, ElementRef } from 'angular2/core';

The alias configured in webpack.config.js

...
resolve: {
    root: [ path.join(__dirname, 'src') ],
    extensions: ['', '.ts', '.js', '.json', '.css', '.html', '.less'],
    alias: {
     ...,
      'angular2/core': path.join(__dirname, 'node_modules', '@angular', 'core', 'index.js'),
     ...
    }
  },
...

The error I'm getting on npm start:

ERROR in [default] C:/workstation/simple-java-mail/src/main/webapp/node_modules/ng2-prism/src/codeblock.component.d.ts:1:66
Cannot find module 'angular2/core'.

Ofcourse ng2-prism should update its dependencies, but this is a situation we will run into sooner or later with one library or another.

But I don't see a reason why the import can't be resolved. What am I missing? I'm not even sure if the issue is with webpack or a config issue in this project seed.

@bbottema
Copy link
Contributor Author

I'm trying my luck on stackoverflow as well.

@PatrickJS
Copy link
Member

the alias are working but it's a typescript issue now.

@PatrickJS
Copy link
Member

@bbottema AppViewManager was removed so the 3rd party module needs to be updated

@bbottema
Copy link
Contributor Author

bbottema commented May 21, 2016

@bbottema AppViewManager was removed so the 3rd party module needs to be updated

_
@gdi2290 Ok, so the error is a little misleading then. Were you able to get this from logging output?

@PatrickJS
Copy link
Member

I'm going to remove the alias as it was only meant to help with beta to rc releases

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants