Skip to content
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"qunitjs": "^2.3.3"
},
"dependencies": {
"ember-rfc176-data": "^0.2.7"
"ember-rfc176-data": "^0.3.0"
},
"directories": {
"test": "tests"
Expand Down
13 changes: 5 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,16 @@ module.exports = function(babel) {
// Flips the ember-rfc176-data mapping into an 'import' indexed object, that exposes the
// default import as well as named imports, e.g. import {foo} from 'bar'
const reverseMapping = {};
Object.keys(mapping).forEach(global => {
const imported = mapping[global];
const importRoot = imported[0];
let importName = imported[1];
if (!importName) {
importName = 'default';
}
mapping.forEach(exportDefinition => {
const imported = exportDefinition.global.substr('Ember.'.length);
const importRoot = exportDefinition.module;
let importName = exportDefinition.export;

if (!reverseMapping[importRoot]) {
reverseMapping[importRoot] = {};
}

reverseMapping[importRoot][importName] = global;
reverseMapping[importRoot][importName] = imported;
});

return {
Expand Down
9 changes: 4 additions & 5 deletions tests/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ function matches(source, expected) {
}

// Ensure each of the config mappings is mapped correctly
Object.keys(mapping).forEach(global => {
const imported = mapping[global];
const importRoot = imported[0];
mapping.forEach(exportDefinition => {
const importRoot = exportDefinition.module;

let importName = imported[1];
let importName = exportDefinition.export;
if (!importName) {
importName = 'default';
}
Expand All @@ -41,7 +40,7 @@ Object.keys(mapping).forEach(global => {
describe(`ember-modules-api-polyfill-${importRoot}-with-${importName}`, () => {
matches(
`import ${localName} from '${importRoot}';`,
`var ${varName} = Ember.${global};`
`var ${varName} = ${exportDefinition.global};`
);
});
});
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,9 @@ ecc-jsbn@~0.1.1:
dependencies:
jsbn "~0.1.0"

ember-rfc176-data@^0.2.7:
version "0.2.7"
resolved "https://registry.yarnpkg.com/ember-rfc176-data/-/ember-rfc176-data-0.2.7.tgz#bd355bc9b473e08096b518784170a23388bc973b"
ember-rfc176-data@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/ember-rfc176-data/-/ember-rfc176-data-0.3.0.tgz#6aee728cb521c5f80710990965027b9c320f6f08"

encoding@^0.1.11:
version "0.1.12"
Expand Down