Modularize the es5-shim package.

This commit is contained in:
Ben Newman
2016-03-11 17:12:59 -05:00
parent 3d54564fa9
commit 4921bc3f0b
6 changed files with 19 additions and 40 deletions

View File

@@ -1,7 +1,7 @@
{
"dependencies": {
"es5-shim": {
"version": "4.3.1"
"version": "4.5.7"
}
}
}

View File

@@ -0,0 +1,5 @@
require("./import_globals.js");
require("es5-shim/es5-shim.js");
require("es5-shim/es5-sham.js");
require("./console.js");
require("./export_globals.js");

View File

@@ -1,5 +1,3 @@
var global = this;
if (global.Date !== Date) {
global.Date = Date;
}
@@ -8,6 +6,10 @@ if (global.parseInt !== parseInt) {
global.parseInt = parseInt;
}
if (global.parseFloat !== parseFloat) {
global.parseFloat = parseFloat;
}
var Sp = String.prototype;
if (Sp.replace !== originalStringReplace) {
// Restore the original value of String#replace, because the es5-shim

View File

@@ -1,5 +1,3 @@
var global = this;
// Because the es5-{shim,sham}.js code assigns to Date and parseInt,
// Meteor treats them as package variables, and so declares them as
// variables in package scope, which causes some references to Date and
@@ -8,6 +6,7 @@ var global = this;
// variables to their appropriate global values.
Date = global.Date;
parseInt = global.parseInt;
parseFloat = global.parseFloat;
// Save the original String#replace method, because es5-shim's
// reimplementation of it causes problems in markdown/showdown.js.

View File

@@ -1,46 +1,16 @@
Package.describe({
name: "es5-shim",
version: "4.3.2-beta.16",
version: "4.5.7-beta.16",
summary: "Shims and polyfills to improve ECMAScript 5 support",
documentation: "README.md"
});
Npm.depends({
"es5-shim": "4.3.1"
"es5-shim": "4.5.7"
});
Package.onUse(function(api) {
// Allow the meteor package to register a weak dependency on this
// package, even though es5-shim implicitly depends on meteor.
api.use("meteor", { unordered: true });
// Initialize Date and parseInt with their initial global values.
api.addFiles("import_globals.js");
// Turn callable console method objects into actual functions.
api.addFiles("console.js", "client");
var es5ShimPath = ".npm/package/node_modules/es5-shim/es5-shim.js";
var es5ShamPath = ".npm/package/node_modules/es5-shim/es5-sham.js";
api.addFiles([
es5ShimPath,
// Limited but necessary polyfills for APIs like Object.create.
es5ShamPath
], "client", {
// Files in the es5-shim package are already wrapped in closures.
bare: true
});
// Only client-side files can be { bare: true }.
api.addFiles(es5ShimPath, "server");
// If Date and parseInt were actually reassigned, make the global
// environment reflect those changes.
api.addFiles("export_globals.js");
// Make sure code that depends on this package gets the new values of
// Date and parseInt.
api.export("Date");
api.export("parseInt");
api.use("modules");
api.mainModule("client.js", "client");
api.mainModule("server.js", "server");
});

View File

@@ -0,0 +1,3 @@
require("./import_globals.js");
require("es5-shim/es5-shim.js");
require("./export_globals.js");