From 95b24153fdcb703bdb36465c952054228e07adc9 Mon Sep 17 00:00:00 2001 From: Sergio Arbeo Date: Mon, 18 Sep 2017 23:43:09 +0200 Subject: [PATCH 1/7] Adapt to new data format This PR adapts the code to the new format suggested in ember-cli/ember-rfc176-data#37. --- package.json | 2 +- src/index.js | 13 +++++-------- tests/index-test.js | 9 ++++----- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index b1c4295..fc4b787 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "qunitjs": "^2.3.3" }, "dependencies": { - "ember-rfc176-data": "^0.2.7" + "ember-rfc176-data": "^0.3.0" }, "directories": { "test": "tests" diff --git a/src/index.js b/src/index.js index 6aa9b66..7370984 100644 --- a/src/index.js +++ b/src/index.js @@ -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 { diff --git a/tests/index-test.js b/tests/index-test.js index 48a0ead..b96c6db 100644 --- a/tests/index-test.js +++ b/tests/index-test.js @@ -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'; } @@ -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};` ); }); }); From 7c61f30d7e5a9e7f0be10f21ee0a6dadead6b642 Mon Sep 17 00:00:00 2001 From: Sergio Arbeo Date: Wed, 20 Sep 2017 15:18:58 +0200 Subject: [PATCH 2/7] Add crappy notifyDeprecation function. --- src/index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/index.js b/src/index.js index 7370984..93636c9 100644 --- a/src/index.js +++ b/src/index.js @@ -13,6 +13,10 @@ function isBlacklisted(blacklist, importPath, exportName) { } } +function notifyDeprecation(msg) { + console.warn(msg); +} + module.exports = function(babel) { const t = babel.types; @@ -74,6 +78,10 @@ module.exports = function(babel) { // Only walk specifiers if this is a module we have a mapping for if (mapping) { + if (mapping.deprecated) { + notifyDeprecation(`Module ${importPath} is deprecated.`); + } + // Iterate all the specifiers and attempt to locate their mapping specifiers.forEach(specifierPath => { let specifier = specifierPath.node; From 0ca032788cc27f3d080cb26c30f0dc91041e2610 Mon Sep 17 00:00:00 2001 From: Sergio Arbeo Date: Wed, 20 Sep 2017 15:39:39 +0200 Subject: [PATCH 3/7] Point ember-rfc176-data to PR branch --- package.json | 2 +- yarn.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index fc4b787..dbf35da 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "qunitjs": "^2.3.3" }, "dependencies": { - "ember-rfc176-data": "^0.3.0" + "ember-rfc176-data": "Turbo87/ember-rfc176-data#new-structure" }, "directories": { "test": "tests" diff --git a/yarn.lock b/yarn.lock index 2e683d7..53ee7d9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -491,9 +491,9 @@ ecc-jsbn@~0.1.1: dependencies: jsbn "~0.1.0" -ember-rfc176-data@^0.2.7: +ember-rfc176-data@Turbo87/ember-rfc176-data#new-structure: version "0.2.7" - resolved "https://registry.yarnpkg.com/ember-rfc176-data/-/ember-rfc176-data-0.2.7.tgz#bd355bc9b473e08096b518784170a23388bc973b" + resolved "https://codeload.github.com/Turbo87/ember-rfc176-data/tar.gz/e590c95e6d68145263dc5820637bdd6726407a37" encoding@^0.1.11: version "0.1.12" From 1abb739f500d825944161f997089e90f4ac9b216 Mon Sep 17 00:00:00 2001 From: Sergio Arbeo Date: Wed, 27 Sep 2017 22:57:06 +0200 Subject: [PATCH 4/7] Added notifier as parameter --- src/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index 93636c9..b2c82c8 100644 --- a/src/index.js +++ b/src/index.js @@ -13,11 +13,11 @@ function isBlacklisted(blacklist, importPath, exportName) { } } -function notifyDeprecation(msg) { - console.warn(msg); +function notifyDeprecation(msg, notifier) { + notifier.warn(msg); } -module.exports = function(babel) { +module.exports = function(babel, notifier = console) { const t = babel.types; // Flips the ember-rfc176-data mapping into an 'import' indexed object, that exposes the @@ -79,7 +79,7 @@ module.exports = function(babel) { if (mapping) { if (mapping.deprecated) { - notifyDeprecation(`Module ${importPath} is deprecated.`); + notifyDeprecation(`Module ${importPath} is deprecated.`, notifier); } // Iterate all the specifiers and attempt to locate their mapping From e1ac0d7f2d33e7f6482720586c107bdcbcd13404 Mon Sep 17 00:00:00 2001 From: Sergio Arbeo Date: Fri, 29 Sep 2017 14:13:28 +0200 Subject: [PATCH 5/7] Fix problem in node 4 --- src/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index b2c82c8..ae02d04 100644 --- a/src/index.js +++ b/src/index.js @@ -17,7 +17,8 @@ function notifyDeprecation(msg, notifier) { notifier.warn(msg); } -module.exports = function(babel, notifier = console) { +module.exports = function(babel, possibleNotifier) { + let notifier = possibleNotifier || console; const t = babel.types; // Flips the ember-rfc176-data mapping into an 'import' indexed object, that exposes the From 5f801436d7677a8f50178914a7dbf30961c929f5 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Tue, 3 Oct 2017 10:55:02 -0400 Subject: [PATCH 6/7] Update to release version of ember-rfc176-data. --- package.json | 2 +- yarn.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index dbf35da..fc4b787 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "qunitjs": "^2.3.3" }, "dependencies": { - "ember-rfc176-data": "Turbo87/ember-rfc176-data#new-structure" + "ember-rfc176-data": "^0.3.0" }, "directories": { "test": "tests" diff --git a/yarn.lock b/yarn.lock index 53ee7d9..d593ca2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -491,9 +491,9 @@ ecc-jsbn@~0.1.1: dependencies: jsbn "~0.1.0" -ember-rfc176-data@Turbo87/ember-rfc176-data#new-structure: - version "0.2.7" - resolved "https://codeload.github.com/Turbo87/ember-rfc176-data/tar.gz/e590c95e6d68145263dc5820637bdd6726407a37" +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" From aed1af628bb27a32c036738be64bfd986a8cf205 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Tue, 3 Oct 2017 10:59:35 -0400 Subject: [PATCH 7/7] Remove deprecation system for now. We definitely should bring this back, but for now we should disable until we can make the deprecations more actionable. --- src/index.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/index.js b/src/index.js index ae02d04..7370984 100644 --- a/src/index.js +++ b/src/index.js @@ -13,12 +13,7 @@ function isBlacklisted(blacklist, importPath, exportName) { } } -function notifyDeprecation(msg, notifier) { - notifier.warn(msg); -} - -module.exports = function(babel, possibleNotifier) { - let notifier = possibleNotifier || console; +module.exports = function(babel) { const t = babel.types; // Flips the ember-rfc176-data mapping into an 'import' indexed object, that exposes the @@ -79,10 +74,6 @@ module.exports = function(babel, possibleNotifier) { // Only walk specifiers if this is a module we have a mapping for if (mapping) { - if (mapping.deprecated) { - notifyDeprecation(`Module ${importPath} is deprecated.`, notifier); - } - // Iterate all the specifiers and attempt to locate their mapping specifiers.forEach(specifierPath => { let specifier = specifierPath.node;