From 3665b31a82f8ded87656d2e79317cf243c40cccb Mon Sep 17 00:00:00 2001 From: David Glasser Date: Thu, 12 Sep 2013 13:55:15 -0700 Subject: [PATCH] Remove backwards-compatibility implementation of pre-0.6.5 Package.register_extension API. It didn't even actually work for producing JavaScript files (eg a coffeescript-like package): see #1410. Package maintainers should have upgraded to the more powerful 0.6.5 API by now anyway. --- History.md | 4 ++ docs/client/concepts.html | 3 +- tools/packages.js | 138 +++----------------------------------- 3 files changed, 13 insertions(+), 132 deletions(-) diff --git a/History.md b/History.md index cda692dbd5..5e6cd7fd65 100644 --- a/History.md +++ b/History.md @@ -7,6 +7,10 @@ Meteor._logoutAllOthers() for logging out other connections logged in as the current user. Log out and close connections for deleted users and tokens. +* The pre-0.6.5 `Package.register_extension` API has been removed. Use + `Package._transitional_registerBuildPlugin` instead, which was introduced in + 0.6.5. (A bug prevented the 0.6.5 reimplementation of `register_extension` + from working properly anyway.) ## v0.6.5.1 diff --git a/docs/client/concepts.html b/docs/client/concepts.html index f0c59d774f..61d47d7c18 100644 --- a/docs/client/concepts.html +++ b/docs/client/concepts.html @@ -913,8 +913,7 @@ quick tips: an example. Build plugins are fully-fledged Meteor programs in their own right and have their own namespace, package dependencies, source files and npm requirements. The old `register_extension` API is - deprecated and should not be used as it will prevent your package - from being cached, slowing down builds. + removed. * It is possible to create weak dependencies between packages. If package A has a weak dependency on package B, it means that diff --git a/tools/packages.js b/tools/packages.js index 2fc9b20975..09290ac63d 100644 --- a/tools/packages.js +++ b/tools/packages.js @@ -695,10 +695,7 @@ _.extend(Slice.prototype, { }); _.each(self._activePluginPackages(), function (otherPkg) { - var all = _.extend({}, otherPkg.sourceHandlers); - _.extend(all, otherPkg.legacyExtensionHandlers); - - _.each(all, function (handler, ext) { + _.each(otherPkg.sourceHandlers, function (handler, ext) { if (ext in ret && ret[ext] !== handler) { buildmessage.error( "conflict: two packages included in " + @@ -794,10 +791,6 @@ var Package = function (library, packageDirectoryForBuildInfo) { // Package metadata. Keys are 'summary' and 'internal'. self.metadata = {}; - // File handler extensions defined by this package. Map from file - // extension to the handler function. - self.legacyExtensionHandlers = {}; - // Available editions/subpackages ("slices") of this package. Array // of Slice. self.slices = []; @@ -1175,125 +1168,12 @@ _.extend(Package.prototype, { // XXX COMPAT WITH 0.6.4 // extension doesn't contain a dot - register_extension: function (extension, callback) { - if (_.has(self.legacyExtensionHandlers, extension)) { - buildmessage.error("duplicate handler for '*." + extension + - "'; only one per package allowed", - { useMyCaller: true }); - // Recover by ignoring the duplicate - return; - } - self.legacyExtensionHandlers[extension] = function (compileStep) { - - // In the old extension API, there is a 'where' parameter - // that conflates architecture and slice name and can be - // either "client" or "server". - var clientOrServer = archinfo.matches(compileStep.arch, "browser") ? - "client" : "server"; - - var api = { - /** - * In the legacy extension API, this is the ultimate low-level - * entry point to add data to the bundle. - * - * type: "js", "css", "head", "body", "static" - * - * path: the (absolute) path at which the file will be - * served. ignored in the case of "head" and "body". - * - * source_file: the absolute path to read the data from. if - * path is set, will default based on that. overridden by - * data. - * - * data: the data to send. overrides source_file if - * present. you must still set path (except for "head" and - * "body".) - */ - add_resource: function (options) { - var sourceFile = options.source_file || options.path; - - var data; - if (options.data) { - data = options.data; - if (!(data instanceof Buffer)) { - if (!(typeof data === "string")) { - buildmessage.error("bad type for 'data'", - { useMyCaller: true }); - // recover by ignoring resource - return; - } - data = new Buffer(data, 'utf8'); - } - } else { - if (!sourceFile) { - buildmessage.error("need either 'source_file' or 'data'", - { useMyCaller: true }); - // recover by ignoring resource - return; - } - data = fs.readFileSync(sourceFile); - } - - if (options.where && options.where !== clientOrServer) { - buildmessage.error("'where' is deprecated here and if " + - "provided must be '" + clientOrServer + "'", - { useMyCaller: true }); - // recover by ignoring resource - return; - } - - var relPath = path.relative(compileStep.rootOutputPath, - options.path); - if (options.type === "js") - compileStep.addJavaScript({ path: relPath, - data: data.toString('utf8') }); - else if (options.type === "head" || options.type === "body") - compileStep.appendDocument({ section: options.type, - data: data.toString('utf8') }); - else if (options.type === "css") - compileStep.addStylesheet({ path: relPath, - data: data.toString('utf8') }); - else if (options.type === "static") - compileStep.addAsset({ path: relPath, data: data }); - }, - - error: function (message) { - buildmessage.error(message, { useMyCaller: true }); - // recover by just continuing - } - }; - - // old-school extension can only take the input as a file on - // disk, so write it out to a temporary file for them. take - // care to preserve the original extension since some legacy - // plugins depend on that (coffeescript.) Also (sigh) put it - // in the same directory as the original file so that - // relative paths work for include files, for plugins that - // care about that. - var tmpdir = path.resolve(path.dirname(compileStep._fullInputPath)); - do { - var tempFilePath = - path.join(tmpdir, "build" + - Math.floor(Math.random() * 1000000) + - "." + path.basename(compileStep.inputPath)); - } while (fs.existsSync(tempFilePath)); - var tempFile = fs.openSync(tempFilePath, "wx"); - try { - var data = compileStep.read(); - fs.writeSync(tempFile, data, 0, data.length); - } finally { - fs.closeSync(tempFile); - } - - try { - callback(api, tempFilePath, - path.join(compileStep.rootOutputPath, - compileStep.inputPath), - clientOrServer); - } finally { - fs.unlinkSync(tempFilePath); - } - }; + register_extension: function () { + buildmessage.error( + "Package.register_extension() is no longer supported. Use " + + "Package._transitional_registerBuildPlugin instead.", + { useMyCaller: true }); + // recover by ignoring }, // Define a plugin. A plugin extends the build process for @@ -1412,7 +1292,6 @@ _.extend(Package.prototype, { // principle of least surprise.) Leave the metadata if we have // it, though. roleHandlers = {use: null, test: null}; - self.legacyExtensionHandlers = {}; self.pluginInfo = {}; npmDependencies = null; } @@ -1649,7 +1528,6 @@ _.extend(Package.prototype, { sources = {use: {client: [], server: []}, test: {client: [], server: []}}; roleHandlers = {use: null, test: null}; - self.legacyExtensionHandlers = {}; self.pluginInfo = {}; npmDependencies = null; } @@ -2160,7 +2038,7 @@ _.extend(Package.prototype, { // True if this package can be saved as a unipackage canBeSavedAsUnipackage: function () { var self = this; - return _.keys(self.legacyExtensionHandlers || []).length === 0; + return true; }, // options: