angular-seed icon indicating copy to clipboard operation
angular-seed copied to clipboard

enable ability to use rxjs-compat

Open danboone opened this issue 7 years ago • 2 comments

I'm submitting a ... (check one with "x")

[X] bug report => search github for a similar issue or PR before submitting

**Current behavior**
Existing project wanting to update project to current state of seed.  Problem is have lots of  code to update for the rxjs breaking change.  so wanted to still update but have  time to update the code as i could.

**Expected behavior**
existing code to compile and app to execute as expected

**Minimal reproduction of the problem with instructions**
rxjs-compat isn't established in the seed anywhere so that it doesn't break existing code.

**What is the motivation / use case for changing the behavior?**
ability to upgrade existing projects to Angular 6 and rxjs 6 and update code as can to fix the breaking change


* **Node:** `node --version` = 8.11.2

danboone avatar Jun 25 '18 17:06 danboone

@danboone just update this file => https://github.com/mgechev/angular-seed/blob/master/tools/tasks/seed/bundle.rxjs.ts

use this code

const Builder = require('systemjs-builder');
const promisify = require('util').promisify;
const fs = require('fs');

async function bundleRxjs(){
  const options = {
    normalize: true,
    runtime: false,
    sourceMaps: true,
    sourceMapContents: false,
    minify: true, 
    mangle: false
  };
  const builder = new Builder('./');
  builder.config({
    paths: {
      'n:*': 'node_modules/*',
      'rxjs/*': 'node_modules/rxjs/*.js',
      "rxjs-compat/*": "node_modules/rxjs-compat/*.js",
      "rxjs/internal-compatibility": "node_modules/rxjs/internal-compatibility/index.js",
      "rxjs/testing": "node_modules/rxjs/testing/index.js",
      "rxjs/ajax": "node_modules/rxjs/ajax/index.js",
      "rxjs/operators": "node_modules/rxjs/operators/index.js",
      "rxjs/webSocket": "node_modules/rxjs/webSocket/index.js",
    },
    map: {
      'rxjs': 'n:rxjs',
      'rxjs-compat': 'n:rxjs-compat'
    },
    packages: {
      'rxjs': { main: 'index.js', defaultExtension: 'js' },
      "rxjs-compat": { main: "index.js", defaultExtension: "js" }
    }
  });
  return builder.bundle('rxjs + rxjs/Rx', 'node_modules/.tmp/Rx.min.js', options)
    .then(output => {
      const writeFile = promisify(fs.writeFile);
      const code = output.source.replace(/rxjs\/index/gm, 'rxjs');
      return writeFile('node_modules/.tmp/Rx.min.js', 
        (options.sourceMaps) 
          ? code + `\n//# sourceMappingURL=Rx.min.js.map`
          : code);
    });
}

aelbore avatar Jul 26 '18 04:07 aelbore

To add to this issue, rxjs-compat may be required by third-party libraries, not just by the application.

tsvetomir avatar Aug 27 '18 11:08 tsvetomir