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

Simplify webpack alias #2974

Merged
merged 2 commits into from
Oct 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .make-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,10 @@ function createImportTargets(importTargets, targetName, targetDirectory) {
"use strict"

var path = require('path');
var dir = path.resolve(__dirname);

module.exports = function(PATH_REPLACEMENT) {
return ${JSON.stringify(importMap, null, 4).replace(/(: )(".+")(,?)/g, "$1path.resolve(PATH_REPLACEMENT, $2)$3")};
module.exports = function() {
return ${JSON.stringify(importMap, null, 4).replace(/(: )"rxjs\/_esm(5|2015)\/(.+")(,?)/g, "$1path.join(dir, \"$3)$4")};
}
`

Expand Down
6 changes: 3 additions & 3 deletions doc/lettable-operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ In order to use the new lettable operators and not gain bundle size, you will ne

Published along with rxjs 5.5 is builds of rxjs in ECMAScript Module format (imports and exports) with both ES5 and ES2015 language level. You can find these distributions in `node_modules/rxjs/_esm5` and `node_modules/rxjs/_esm2015` ("esm" stands for ECMAScript Modules and the number "5" or "2015" is for the ES language level). In your application source code, you should import from `rxjs/operators`, but in your Webpack configuration file you will need to re-map imports to the ESM5 (or ESM2015) version.

If you `require('rxjs/_esm5/path-mapping')`, you will receive a function that takes a path to your node modules (or any directory containing the rxjs distribution) and returns an object of key-value pairs mapping each input to it's file location on disk. Utilize this mapping as follows:
If you `require('rxjs/_esm5/path-mapping')`, you will receive a function that returns an object of key-value pairs mapping each input to it's file location on disk. Utilize this mapping as follows:

**webpack.config.js**

Expand All @@ -134,7 +134,7 @@ module.exports = {
output: 'bundle.js',
resolve: {
// Use the "alias" key to resolve to an ESM distribution
alias: rxPaths(path.resolve(__dirname, 'node_modules'))
alias: rxPaths()
},
plugins: [
new webpack.optimize.ModuleConcatenationPlugin()
Expand Down Expand Up @@ -179,7 +179,7 @@ var config = {
resolve: {
extensions: [".ts", ".js"],
modules: [path.resolve('./src'), 'node_modules'],
alias: rxPaths(path.resolve(__dirname, 'node_modules'))
alias: rxPaths()
},
plugins: [
new webpack.DefinePlugin({
Expand Down