From 4921bc3f0b4e96ae7d279a66cfb83a43dc4e83fb Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Fri, 11 Mar 2016 17:12:59 -0500 Subject: [PATCH] Modularize the es5-shim package. --- .../es5-shim/.npm/package/npm-shrinkwrap.json | 2 +- packages/es5-shim/client.js | 5 +++ packages/es5-shim/export_globals.js | 6 ++- packages/es5-shim/import_globals.js | 3 +- packages/es5-shim/package.js | 40 +++---------------- packages/es5-shim/server.js | 3 ++ 6 files changed, 19 insertions(+), 40 deletions(-) create mode 100644 packages/es5-shim/client.js create mode 100644 packages/es5-shim/server.js diff --git a/packages/es5-shim/.npm/package/npm-shrinkwrap.json b/packages/es5-shim/.npm/package/npm-shrinkwrap.json index b4c0bc1e15..aabf68b740 100644 --- a/packages/es5-shim/.npm/package/npm-shrinkwrap.json +++ b/packages/es5-shim/.npm/package/npm-shrinkwrap.json @@ -1,7 +1,7 @@ { "dependencies": { "es5-shim": { - "version": "4.3.1" + "version": "4.5.7" } } } diff --git a/packages/es5-shim/client.js b/packages/es5-shim/client.js new file mode 100644 index 0000000000..aa0d54b091 --- /dev/null +++ b/packages/es5-shim/client.js @@ -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"); diff --git a/packages/es5-shim/export_globals.js b/packages/es5-shim/export_globals.js index c0b791eedc..dcf38e47c8 100644 --- a/packages/es5-shim/export_globals.js +++ b/packages/es5-shim/export_globals.js @@ -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 diff --git a/packages/es5-shim/import_globals.js b/packages/es5-shim/import_globals.js index 9b3bb6f3ac..6c7fa12759 100644 --- a/packages/es5-shim/import_globals.js +++ b/packages/es5-shim/import_globals.js @@ -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. diff --git a/packages/es5-shim/package.js b/packages/es5-shim/package.js index f96d989881..66521497a9 100644 --- a/packages/es5-shim/package.js +++ b/packages/es5-shim/package.js @@ -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"); }); diff --git a/packages/es5-shim/server.js b/packages/es5-shim/server.js new file mode 100644 index 0000000000..9731c36c32 --- /dev/null +++ b/packages/es5-shim/server.js @@ -0,0 +1,3 @@ +require("./import_globals.js"); +require("es5-shim/es5-shim.js"); +require("./export_globals.js");