Skip to content

Commit

Permalink
feat(umd): UMD now mirrors export schema for ESM and CJS
Browse files Browse the repository at this point in the history
For example, if you want to do the same thing as  but using the global file, you would use , If you wanted to do , that will be available at . Thus making the import/access points more predictable between the UMD and the ESM and CJS versions.
  • Loading branch information
benlesh committed Mar 13, 2018
1 parent 1b69bd6 commit ad4a8b5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
8 changes: 4 additions & 4 deletions .make-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ fs.copySync('src/testing/package.json', PKG_ROOT + '/testing/package.json');
if (fs.existsSync(UMD_ROOT)) {
fs.copySync(UMD_ROOT, UMD_PKG);
// Add licenses to tops of bundles
addLicenseToFile('LICENSE.txt', UMD_PKG + 'Rx.js');
addLicenseTextToFile(license, UMD_PKG + 'Rx.min.js');
addLicenseToFile('LICENSE.txt', UMD_PKG + 'Rx.js');
addLicenseTextToFile(license, UMD_PKG + 'Rx.min.js');
addLicenseToFile('LICENSE.txt', UMD_PKG + 'rxjs.umd.js');
addLicenseTextToFile(license, UMD_PKG + 'rxjs.umd.min.js');
addLicenseToFile('LICENSE.txt', UMD_PKG + 'rxjs.umd.js');
addLicenseTextToFile(license, UMD_PKG + 'rxjs.umd.min.js');
}

function copySources(rootDir, packageDir, ignoreMissing) {
Expand Down
10 changes: 5 additions & 5 deletions src/internal/umd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
*/

/* rxjs */
export * from '../';
export * from '../index';

/* rxjs.operators */
import * as _operators from '../operators';
import * as _operators from '../operators/index';
export const operators = _operators;

/* rxjs.testing */
import * as _testing from '../testing';
import * as _testing from '../testing/index';
export const testing = _testing;

/* rxjs.ajax */
import * as _ajax from '../ajax';
import * as _ajax from '../ajax/index';
export const ajax = _ajax;

/* rxjs.websocket */
import * as _websocket from '../websocket';
import * as _websocket from '../websocket/index';
export const websocket = _websocket;
6 changes: 3 additions & 3 deletions tools/make-closure-core.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var compiler = require('google-closure-compiler-js').compile;
var fs = require('fs');

var source = fs.readFileSync('dist/global/Rx.js', 'utf8');
var source = fs.readFileSync('dist/global/rxjs.umd.js', 'utf8');

var compilerFlags = {
jsCode: [{src: source}],
Expand All @@ -11,5 +11,5 @@ var compilerFlags = {

var output = compiler(compilerFlags);

fs.writeFileSync('dist/global/Rx.min.js', output.compiledCode, 'utf8');
fs.writeFileSync('dist/global/Rx.min.js.map', output.sourceMap, 'utf8');
fs.writeFileSync('dist/global/rxjs.umd.min.js', output.compiledCode, 'utf8');
fs.writeFileSync('dist/global/rxjs.umd.min.js.map', output.sourceMap, 'utf8');
8 changes: 4 additions & 4 deletions tools/make-umd-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var path = require('path');
var tslib = require('tslib');

rollup.rollup({
entry: 'dist/esm5_for_rollup/internal/Rx.js',
entry: 'dist/esm5_for_rollup/internal/umd.js',
plugins: [
rollupNodeResolve({
jsnext: true,
Expand All @@ -25,10 +25,10 @@ rollup.rollup({
}).then(function (bundle) {
var result = bundle.generate({
format: 'umd',
moduleName: 'Rx',
moduleName: 'rxjs',
sourceMap: true
});

fs.writeFileSync('dist/global/Rx.js', result.code);
fs.writeFileSync('dist/global/Rx.js.map', result.map);
fs.writeFileSync('dist/global/rxjs.umd.js', result.code);
fs.writeFileSync('dist/global/rxjs.umd.js.map', result.map);
});
5 changes: 4 additions & 1 deletion tsconfig/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

// legacy entry-points
"../dist/src/internal/Rx.ts",
"../dist/src/add/observable/of.ts"
"../dist/src/add/observable/of.ts",

// umd entry-point
"../dist/src/internal/umd.ts",
]
}

0 comments on commit ad4a8b5

Please sign in to comment.