Skip to content

Get rid of require() in vendor.ts #236

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

Closed
antonmoiseev opened this issue Jan 19, 2016 · 3 comments
Closed

Get rid of require() in vendor.ts #236

antonmoiseev opened this issue Jan 19, 2016 · 3 comments

Comments

@antonmoiseev
Copy link
Contributor

Currently vendor.ts uses require() to import the enableProdMode function from angular2/core:

if ('production' === process.env.ENV) {
  let ngCore = require('angular2/core');
  ngCore.enableProdMode();
}

Can we combine the function import together with the ES6 import statement below in the file?

//...
import 'angular2/http';
import {enableProdMode} 'angular2/core';

if ('production' === process.env.ENV) {
  enableProdMode();
}

My understanding is that all required objects from angular2/core still will be bundled since the application code explicitly imports everything it needs. However I lack the knowledge of Webpack's bundling process and concerned that some of the objects from angular2/core can leak into the bundle.js file instead of being in vendor.bundle.js.

I did a quick experiment it seems that everything is fine, works as intended, but maybe I'm missing a common case when it won't work. What do you think?

@PatrickJS
Copy link
Owner

this works but I was trying to be more consistent showing that modules where we want to toggle features per enviroment should use require

@antonmoiseev
Copy link
Contributor Author

I see. Frankly I'd rather do not mix different module format styles in an app unless there is no way to avoid require(). But please feel free to close the issue if you are not looking into changing this.

@PatrickJS
Copy link
Owner

we still have to mix import and require :/ even with webpack2. I'm mixing both to stay consistent in case the devloper deletes the if statement the core will still remained bundled correctly. We also have a problem with typescript not supporting other than TS modules see microsoft/TypeScript#2709 I'm going to close this issue but if you have anymore questions feel free to open an issue

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