angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.74k stars 11.98k forks source link

webpack externals not working with tests #8086

Closed darkbasic closed 6 years ago

darkbasic commented 6 years ago

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.4.7 (e)
node: 8.7.0
os: linux x64
@angular/animations: 4.4.5
@angular/common: 4.4.5
@angular/compiler: 4.4.5
@angular/core: 4.4.5
@angular/forms: 4.4.5
@angular/http: 4.4.5
@angular/platform-browser: 4.4.5
@angular/platform-browser-dynamic: 4.4.5
@angular/router: 4.4.5
@angular/cli: 1.4.7
@angular/compiler-cli: 4.4.5
@angular/language-service: 4.4.5
typescript: 2.3.4
typescript-extends: 1.0.1

Repro steps.

git clone https://github.com/darkbasic/angularcli-meteor.git
cd angularcli-meteor
npm install
Install Meteor: https://www.meteor.com/install
./node_modules/.bin/meteor-client bundle -s api
npm run test

The log given by the failure.

Chrome 62.0.3202 (Linux 0.0.0) ERROR
  Uncaught ReferenceError: Mongo is not defined
  at http://localhost:9876/_karma_webpack_/vendor.bundle.js:354

Desired functionality.

Mention any other details that might be useful.

Hi, I'm working to integrate angular-cli with meteor-client-bundler: https://github.com/darkbasic/angularcli-meteor For the moment I'm simply ejecting the config, even if I would love to get to a solution which does not require to do so in the future.

Basically I'm using Webpack externals to resolve the meteor namespace.

import { Mongo } from 'meteor/mongo';

The reason why I'm doing this is because we use our own custom bundler rather than relying on Meteor's bundler, where this logic already exists.

https://github.com/darkbasic/angularcli-meteor/blob/master/patches/webpack.config.js.patch https://github.com/darkbasic/angularcli-meteor/blob/master/webpack.config.js.dev

Everything works flowlessly when I run npm run start, but unfortunately I get

Uncaught ReferenceError: Mongo is not defined

when trying to run tests. Is the module resolution different for tests? How can I solve this?

Thanks

angular-automatic-lock-bot[bot] commented 5 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.