Skip to content

Commit

Permalink
Support New module imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaurav0 committed Jun 2, 2018
1 parent e097014 commit 03af707
Show file tree
Hide file tree
Showing 9 changed files with 474 additions and 189 deletions.
4 changes: 2 additions & 2 deletions app/app.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Ember from 'ember';
import Application from '@ember/application';
import Resolver from './resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';

const App = Ember.Application.extend({
const App = Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver
Expand Down
4 changes: 2 additions & 2 deletions app/router.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Ember from 'ember';
import EmberRouter from '@ember/routing/router';
import config from './config/environment';

const Router = Ember.Router.extend({
const Router = EmberRouter.extend({
location: config.locationType,
rootURL: config.rootURL
});
Expand Down
8 changes: 6 additions & 2 deletions app/services/ember-cli.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Babel from 'babel-core';
import Path from 'path';
import HbsPlugin from '../plugins/hbs-plugin';
import NewModulesPlugin from 'babel-plugin-ember-modules-api-polyfill';
import blueprints from '../lib/blueprints';
import Ember from 'ember';
import moment from 'moment';
Expand All @@ -11,6 +12,7 @@ const { computed, inject, RSVP, run, $, testing } = Ember;
const twiddleAppName = 'twiddle';
const oldTwiddleAppNames = ['demo-app', 'app'];
const hbsPlugin = new HbsPlugin(Babel);
const newModulesPlugin = new NewModulesPlugin(Babel);

// These files will be included if not present
const boilerPlateJs = [
Expand Down Expand Up @@ -447,7 +449,8 @@ export default Ember.Service.extend({
compileJs(code, filePath) {
code = this.fixTwiddleAppNames(code);
let moduleName = this.nameWithModule(filePath);
return Babel.transform(code, babelOpts(moduleName)).code;
let output = Babel.transform(code, babelOpts(moduleName)).code;
return output;
},

/**
Expand Down Expand Up @@ -516,7 +519,8 @@ function babelOpts(moduleName) {
loose: true,
noInterop: true
}],
hbsPlugin
hbsPlugin,
newModulesPlugin
]
};
}
Expand Down
4 changes: 4 additions & 0 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ module.exports = function(defaults) {
app.import('vendor/bootstrap-dropdown-submenu-fix.css');
app.import('vendor/hint.css');

app.import('node_modules/babel-plugin-ember-modules-api-polyfill/src/index.js', {
using: [{ transformation: 'cjs', as: 'babel-plugin-ember-modules-api-polyfill' }]
});

let loaderTree = funnel(path.dirname(require.resolve('loader.js')), {
files: ['loader.js'],
destDir: '/assets'
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"author": "Ember Twiddle Contributors",
"license": "MIT",
"devDependencies": {
"babel-plugin-ember-modules-api-polyfill": "^2.3.0",
"babel-preset-es2017": "^6.24.1",
"babel-standalone": "^6.26.0",
"broccoli-asset-rev": "^2.4.5",
Expand All @@ -29,11 +30,12 @@
"ember-ajax": "^3.0.0",
"ember-api-actions": "~0.1.8",
"ember-autoresize": "~0.6.1",
"ember-cli": "2.15.1",
"ember-cli": "2.16.2",
"ember-cli-app-version": "^3.0.0",
"ember-cli-babel": "^6.12.0",
"ember-cli-bootstrap-sassy": "~0.5.8",
"ember-cli-build-notifications": "~0.2.0",
"ember-cli-cjs-transform": "gaurav0/ember-cli-cjs-transform#json",
"ember-cli-code-coverage": "~0.3.12 ",
"ember-cli-dependency-checker": "^2.1.0",
"ember-cli-deploy": "^1.0.2",
Expand Down Expand Up @@ -71,8 +73,9 @@
"ember-notify": "^5.2.1",
"ember-resolver": "^4.0.0",
"ember-responsive": "^2.0.8",
"ember-rfc176-data": "~0.3.2",
"ember-route-action-helper": "^2.0.6",
"ember-source": "~2.15.0",
"ember-source": "~2.16.0",
"ember-test-helpers": "~0.6.3",
"eslint-plugin-ember": "^5.1.0",
"ivy-codemirror": "^2.1.0",
Expand Down
4 changes: 2 additions & 2 deletions tests/helpers/destroy-app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Ember from 'ember';
import { run } from '@ember/runloop';

export default function destroyApp(application) {
Ember.run(() => {
run(() => {
application.destroy();
window.server.shutdown();
});
Expand Down
6 changes: 2 additions & 4 deletions tests/helpers/module-for-acceptance.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { module } from 'qunit';
import Ember from 'ember';
import { resolve } from 'rsvp';
import startApp from '../helpers/start-app';
import destroyApp from '../helpers/destroy-app';

const { RSVP: { Promise } } = Ember;

export default function(name, options = {}) {
module(name, {
beforeEach() {
Expand All @@ -17,7 +15,7 @@ export default function(name, options = {}) {

afterEach() {
let afterEach = options.afterEach && options.afterEach.apply(this, arguments);
return Promise.resolve(afterEach).then(() => destroyApp(this.application));
return resolve(afterEach).then(() => destroyApp(this.application));
}
});
}
6 changes: 2 additions & 4 deletions tests/helpers/start-app.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import Ember from 'ember';
import Application from '../../app';
import config from '../../config/environment';

const { run } = Ember;
const assign = Ember.assign || Ember.merge;
import { run } from '@ember/runloop';
import { assign } from '@ember/polyfills';

export default function startApp(attrs) {
let application;
Expand Down
Loading

0 comments on commit 03af707

Please sign in to comment.