Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move packages/**/lib/main.js to packages/**/lib/index.js. #12648

Merged
merged 4 commits into from
Nov 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
"babel-plugin-filter-imports": "~0.2.0",
"bower": "~1.3.2",
"chalk": "^0.5.1",
"ember-cli-dependency-checker": "^1.0.1",
"ember-cli": "^1.13.13",
"ember-cli-dependency-checker": "^1.0.1",
"ember-cli-sauce": "^1.4.2",
"ember-cli-yuidoc": "0.7.0",
"ember-publisher": "0.0.7",
"emberjs-build": "0.4.7",
"emberjs-build": "0.5.2",
"express": "^4.5.0",
"finalhandler": "^0.4.0",
"github": "^0.2.3",
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion packages/ember-metal/lib/core.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/*globals Ember:true,ENV,EmberENV */

import require from 'require';

/**
@module ember
@submodule ember-metal
Expand Down Expand Up @@ -47,7 +49,7 @@ Ember.toString = function() { return 'Ember'; };

// The debug functions are exported to globals with `require` to
// prevent babel-plugin-filter-imports from removing them.
let debugModule = Ember.__loader.require('ember-metal/debug');
let debugModule = require('ember-metal/debug');
Ember.assert = debugModule.assert;
Ember.warn = debugModule.warn;
Ember.debug = debugModule.debug;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

// BEGIN IMPORTS
import require, { has } from 'require';
import Ember from 'ember-metal/core';
import { deprecateFunc } from 'ember-metal/debug';
import isEnabled, { FEATURES } from 'ember-metal/features';
Expand Down Expand Up @@ -358,8 +359,8 @@ Ember.onerror = null;
// do this for side-effects of updating Ember.assert, warn, etc when
// ember-debug is present
// This needs to be called before any deprecateFunc
if (Ember.__loader.registry['ember-debug']) {
requireModule('ember-debug');
if (has('ember-debug')) {
require('ember-debug');
} else {
Ember.Debug = { };

Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions packages/ember-runtime/lib/ext/rsvp.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* globals RSVP:true */

import Ember from 'ember-metal/core';
import require, { has } from 'require';
import { assert } from 'ember-metal/debug';
import Logger from 'ember-metal/logger';
import run from 'ember-metal/run_loop';
Expand Down Expand Up @@ -57,8 +58,8 @@ export function onerrorDefault(reason) {
if (error && error.name !== 'TransitionAborted') {
if (Ember.testing) {
// ES6TODO: remove when possible
if (!Test && Ember.__loader.registry[testModuleName]) {
Test = requireModule(testModuleName)['default'];
if (!Test && has(testModuleName)) {
Test = require(testModuleName)['default'];
}

if (Test && Test.adapter) {
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions packages/ember-template-compiler/lib/compat/precompile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
@module ember
@submodule ember-template-compiler
*/
import Ember from 'ember-metal/core';
import require, { has } from 'require';
import compileOptions from 'ember-template-compiler/system/compile_options';

var compile, compileSpec;

export default function(string) {
if ((!compile || !compileSpec) && Ember.__loader.registry['htmlbars-compiler/compiler']) {
var Compiler = requireModule('htmlbars-compiler/compiler');
if ((!compile || !compileSpec) && has('htmlbars-compiler/compiler')) {
var Compiler = require('htmlbars-compiler/compiler');

compile = Compiler.compile;
compileSpec = Compiler.compileSpec;
Expand Down
6 changes: 3 additions & 3 deletions packages/ember-template-compiler/lib/system/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@submodule ember-template-compiler
*/

import Ember from 'ember-metal/core';
import require, { has } from 'require';
import compileOptions from 'ember-template-compiler/system/compile_options';
import template from 'ember-template-compiler/system/template';

Expand All @@ -20,8 +20,8 @@ var compile;
@param {Object} options This is an options hash to augment the compiler options.
*/
export default function(templateString, options) {
if (!compile && Ember.__loader.registry['htmlbars-compiler/compiler']) {
compile = requireModule('htmlbars-compiler/compiler').compile;
if (!compile && has('htmlbars-compiler/compiler')) {
compile = require('htmlbars-compiler/compiler').compile;
}

if (!compile) {
Expand Down
6 changes: 3 additions & 3 deletions packages/ember-template-compiler/lib/system/precompile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@module ember
@submodule ember-template-compiler
*/
import Ember from 'ember-metal/core';
import require, { has } from 'require';
import compileOptions from 'ember-template-compiler/system/compile_options';

var compileSpec;
Expand All @@ -18,8 +18,8 @@ var compileSpec;
@param {String} templateString This is the string to be compiled by HTMLBars.
*/
export default function(templateString, options) {
if (!compileSpec && Ember.__loader.registry['htmlbars-compiler/compiler']) {
compileSpec = requireModule('htmlbars-compiler/compiler').compileSpec;
if (!compileSpec && has('htmlbars-compiler/compiler')) {
compileSpec = require('htmlbars-compiler/compiler').compileSpec;
}

if (!compileSpec) {
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions packages/ember/lib/main.js → packages/ember/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import 'ember-htmlbars';
import 'ember-routing-htmlbars';
import 'ember-routing-views';

import Ember from 'ember-metal/core';
import require, { has } from 'require';
import { runLoadHooks } from 'ember-runtime/system/lazy_load';

if (Ember.__loader.registry['ember-template-compiler']) {
requireModule('ember-template-compiler');
if (has('ember-template-compiler')) {
require('ember-template-compiler');
}

// do this to ensure that Ember.Test is defined properly on the global
// if it is present.
if (Ember.__loader.registry['ember-testing']) {
requireModule('ember-testing');
if (has('ember-testing')) {
require('ember-testing');
}

runLoadHooks('Ember');
Expand Down
21 changes: 17 additions & 4 deletions packages/loader/lib/main.js → packages/loader/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ var mainContext = this;
requirejs = require = requireModule = function(name) {
return internalRequire(name, null);
}

// setup `require` module
require['default'] = require;

require.has = function registryHas(moduleName) {
return !!registry[moduleName] || !!registry[moduleName + '/index'];
};

function missingModule(name, referrerName) {
if (referrerName) {
throw new Error('Could not find module ' + name + ' required by: ' + referrerName);
Expand All @@ -42,7 +48,15 @@ var mainContext = this;
}
}

function internalRequire(name, referrerName) {
function internalRequire(_name, referrerName) {
var name = _name;
var mod = registry[name];

if (!mod) {
name = name + '/index';
mod = registry[name];
}

var exports = seen[name];

if (exports !== undefined) {
Expand All @@ -51,11 +65,10 @@ var mainContext = this;

exports = seen[name] = {};

if (!registry[name]) {
missingModule(name, referrerName);
if (!mod) {
missingModule(_name, referrerName);
}

var mod = registry[name];
var deps = mod.deps;
var callback = mod.callback;
var length = deps.length;
Expand Down