Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bbottema opened this issue May 19, 2016 · 3 comments
Closed

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

bbottema opened this issue May 19, 2016 · 3 comments

Comments

@bbottema
Copy link

bbottema commented May 19, 2016

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
Author

I'm trying my luck on stackoverflow as well.

@ludohenin
Copy link
Collaborator

@bbottema We are not using webpack in this seed. Closing as this not related to the seed. Thanks.

@bbottema
Copy link
Author

bbottema commented May 20, 2016

@ludohenin sorry, I clicked the wrong project seed in Google (it has the same name, different github user).

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

No branches or pull requests

2 participants