Skip to content

Commit

Permalink
Revert the contents of the avital-client-compatibility branch.
Browse files Browse the repository at this point in the history
We will rebase linker on top of this commit, and then re-apply.
  • Loading branch information
glasser committed May 13, 2013
1 parent 8dbee56 commit 6f05a29
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 36 deletions.
6 changes: 0 additions & 6 deletions docs/client/concepts.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ <h2 id="structuringyourapp">Structuring your application</h2>
You're free to use a single JavaScript file for your entire application, or
create a nested tree of separate files, or anything in between.

Some JavaScript libraries only work when placed in the
`client/compatibility` subdirectory. Files in this directory are
executed without being wrapped in a new variable scope. This means
that each top-level `var` defines a global variable. In addition,
these files are executed before other client-side JavaScript files.

Files outside the `client`, `server` and `tests` subdirectories are loaded on
both the client and the server! That's the place for model definitions and
other functions. Meteor provides the variables [`isClient`](#meteor_isclient) and
Expand Down
5 changes: 2 additions & 3 deletions packages/meteor/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ Package.describe({
});

Package.register_extension(
"js", function (bundle, source_path, serve_path, where, opt) {
"js", function (bundle, source_path, serve_path, where) {
bundle.add_resource({
type: "js",
path: serve_path,
source_file: source_path,
where: where,
raw: opt.raw
where: where
});
}
);
Expand Down
26 changes: 6 additions & 20 deletions tools/bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ var PackageBundlingInfo = function (pkg, bundle) {
});
},

add_files: function (paths, where, opt) {
add_files: function (paths, where) {
if (!(paths instanceof Array))
paths = paths ? [paths] : [];
if (!(where instanceof Array))
where = where ? [where] : [];

_.each(where, function (w) {
_.each(paths, function (rel_path) {
self.add_file(rel_path, w, opt);
self.add_file(rel_path, w);
});
});
},
Expand Down Expand Up @@ -188,11 +188,8 @@ _.extend(PackageBundlingInfo.prototype, {
return candidates[0];
},

// opt {Object}
// - raw {Boolean} In case this is a JS file, don't wrap in a closure.
add_file: function (rel_path, where, opt) {
add_file: function (rel_path, where) {
var self = this;
opt = opt || {};

if (self.files[where][rel_path])
return;
Expand All @@ -213,8 +210,7 @@ _.extend(PackageBundlingInfo.prototype, {
handler(self.bundle.api,
sourcePath,
path.join(self.pkg.serve_root, rel_path),
where,
opt);
where);
} else {
// If we don't have an extension handler, serve this file
// as a static resource.
Expand Down Expand Up @@ -306,10 +302,6 @@ var Bundle = function () {
*
* data: the data to send. overrides source_file if present. you
* must still set path (except for "head" and "body".)
*
* raw: (only for js files) when set, don't wrap code in
* a closure. used for client-side javascript libraries that use
* the `function foo()` or `var foo =` syntax to define globals.
*/
add_resource: function (options) {
var source_file = options.source_file || options.path;
Expand Down Expand Up @@ -345,17 +337,11 @@ var Bundle = function () {
// scope (eg, file-level vars are file-scoped). On the server, this
// is done in server/server.js to inject the Npm symbol.
//
// Some client-side Javascript libraries define globals
// with `var foo =` or `function bar()` which only work if
// loaded directly from a script tag. If
// `options.raw` is set, don't wrap in a closure
// to enable using such libraries.
//
// The ".call(this)" allows you to do a top-level "this.foo = "
// to define global variables when using "use strict"
// (http://es5.github.io/#x15.3.4.4); this is the only way to do
// it in CoffeeScript.
if (w === "client" && !options.raw) {
if (w === "client") {
wrapped = Buffer.concat([
new Buffer("(function(){ "),
data,
Expand Down Expand Up @@ -687,7 +673,7 @@ _.extend(Bundle.prototype, {
contents = self.files.client[file];
delete self.files.client[file];
self.files.client_cacheable[file] = contents;
url = file + '?' + sha1(contents);
url = file + '?' + sha1(contents)
}
else
throw new Error('unable to find file: ' + file);
Expand Down
8 changes: 1 addition & 7 deletions tools/packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,7 @@ _.extend(Package.prototype, {
api.use(project.get_packages(app_dir));

// -- Source files --
var shouldLoadRaw = function (filename) {
return filename.indexOf(path.sep + 'client' + path.sep + 'compatibility' + path.sep) !== -1;
};
var clientFiles = sources_except(api, "server");
api.add_files(_.filter(clientFiles, shouldLoadRaw), "client", {raw: true});
api.add_files(_.reject(clientFiles, shouldLoadRaw), "client");

api.add_files(sources_except(api, "server"), "client");
api.add_files(sources_except(api, "client"), "server");
});

Expand Down

0 comments on commit 6f05a29

Please sign in to comment.