Skip to content

Commit

Permalink
Remove internal usage of Ember.__loader.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Nov 27, 2015
1 parent 0770bdd commit 89f0516
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 19 deletions.
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
5 changes: 3 additions & 2 deletions packages/ember-metal/lib/index.js
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/index']) {
requireModule('ember-debug');
if (has('ember-debug')) {
require('ember-debug');
} else {
Ember.Debug = { };

Expand Down
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
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
10 changes: 5 additions & 5 deletions 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/index']) {
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/index']) {
requireModule('ember-testing');
if (has('ember-testing')) {
require('ember-testing');
}

runLoadHooks('Ember');
Expand Down
6 changes: 6 additions & 0 deletions 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 Down

0 comments on commit 89f0516

Please sign in to comment.