fix(language-service): do not overwrite native `Reflect` (#24299)

Fixes #21420

PR Close #24299
This commit is contained in:
George Kalpakas 2018-06-04 22:38:08 +03:00 committed by Miško Hevery
parent 3980640d53
commit 68814040e3
2 changed files with 5 additions and 18 deletions

View File

@ -4,8 +4,9 @@
* License: MIT
*/
var $reflect = {defineMetadata: function() {}, getOwnMetadata: function(){}};
((typeof global !== 'undefined' && global)||{})['Reflect'] = $reflect;
var $reflect = {defineMetadata: function() {}, getOwnMetadata: function() {}};
var Reflect = (typeof global !== 'undefined' ? global : {})['Reflect'] || {};
Object.keys($reflect).forEach(function(key) { Reflect[key] = Reflect[key] || $reflect[key]; });
var $deferred, $resolved, $provided;
function $getModule(name) { return $provided[name] || require(name); }
function define(modules, cb) { $deferred = { modules: modules, cb: cb }; }

View File

@ -9,12 +9,12 @@
const commonjs = require('rollup-plugin-commonjs');
const sourcemaps = require('rollup-plugin-sourcemaps');
const path = require('path');
const fs = require('fs');
var m = /^\@angular\/((\w|\-)+)(\/(\w|\d|\/|\-)+)?$/;
var location = normalize('../../dist/packages-dist') + '/';
var rxjsLocation = normalize('../../node_modules/rxjs');
var tslibLocation = normalize('../../node_modules/tslib');
var esm = 'esm/';
var locations = {'compiler-cli': normalize('../../dist/packages') + '/'};
@ -43,21 +43,7 @@ function resolve(id, from) {
}
}
var banner = `
var $reflect = {defineMetadata: function() {}, getOwnMetadata: function(){}};
((typeof global !== 'undefined' && global)||{})['Reflect'] = $reflect;
var $deferred, $resolved, $provided;
function $getModule(name) { return $provided[name] || require(name); }
function define(modules, cb) { $deferred = { modules: modules, cb: cb }; }
module.exports = function(provided) {
if ($resolved) return $resolved;
var result = {};
$provided = Object.assign({'reflect-metadata': $reflect}, provided || {}, { exports: result });
$deferred.cb.apply(this, $deferred.modules.map($getModule));
$resolved = result;
return result;
}
`;
var banner = fs.readFileSync('bundles/banner.js.txt', 'utf8');
module.exports = {
entry: '../../dist/packages-dist/language-service/fesm5/language-service.js',