Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
['Ember.RouterDSL', 'ember-routing'],
['Ember.Router', 'ember-routing'],
['Ember.Route', 'ember-routing'],
['Ember.Application', 'ember-application'],
['Ember.ApplicationInstance', 'ember-application'],
['Ember.Engine', 'ember-application'],
['Ember.EngineInstance', 'ember-application'],
['Ember.Resolver', 'ember-application'],
['Ember.DefaultResolver', 'ember-application', 'Resolver'],
['Ember.DataAdapter', 'ember-extension-support'],
['Ember.ContainerDebugAdapter', 'ember-extension-support'],
];
const fs = require('fs-extra');
const path = require('path');
let moduleNames = new Set(mappings.filter(m => !m.deprecated).map(m => m.module));
moduleNames.forEach(moduleName => {
let contents = '';
mappings.filter(m => m.module === moduleName).forEach(m => {
let exportForGlobal = allExports.find(e => e[0] === m.global);
if (!exportForGlobal) {
console.log('could not find: ' + m.global);
if (m.export === 'default') {
contents += `// TODO: export default ${m.global};\n`;
} else {
contents += `// TODO: export const ${m.export} = ${m.global};\n`;
}
} else {
let exportName = exportForGlobal[2] || exportForGlobal[0].slice(6);
moduleNames.forEach(moduleName => {
let contents = '';
mappings.filter(m => m.module === moduleName).forEach(m => {
let exportForGlobal = allExports.find(e => e[0] === m.global);
if (!exportForGlobal) {
console.log('could not find: ' + m.global);
if (m.export === 'default') {
contents += `// TODO: export default ${m.global};\n`;
} else {
contents += `// TODO: export const ${m.export} = ${m.global};\n`;
}
} else {
let exportName = exportForGlobal[2] || exportForGlobal[0].slice(6);
if (m.export === 'default') {
contents += `export { ${exportName} as default } from '${exportForGlobal[1]}';\n`;
} else if (m.export === exportName) {
'use strict';
const MAPPING = require('ember-rfc176-data');
const { buildMessage, getFullNames, isDestructuring } = require('../utils/new-module');
const { getSourceModuleNameForIdentifier } = require('../utils/import');
const GLOBALS = MAPPING.reduce((memo, exportDefinition) => {
if (exportDefinition.deprecated) {
return memo;
}
if (exportDefinition.global in memo) {
return memo;
}
memo[exportDefinition.global] = exportDefinition; // eslint-disable-line no-param-reassign
return memo;
}, Object.create(null));
//------------------------------------------------------------------------------
// General rule - Use "New Module Imports" from Ember RFC #176
//------------------------------------------------------------------------------
'use strict';
const MAPPING = require('ember-rfc176-data');
const GLOBALS = MAPPING.reduce((memo, exportDefinition) => {
if (!exportDefinition.deprecated) {
return memo;
}
if (!exportDefinition.replacement) {
return memo;
}
const exportName = exportDefinition.export;
const moduleName = exportDefinition.module;
if (!(moduleName in memo)) {
memo[moduleName] = {}; // eslint-disable-line no-param-reassign
}
memo[moduleName][exportName] = exportDefinition; // eslint-disable-line no-param-reassign
module.exports = function(babel) {
const t = babel.types;
// 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 = {};
mapping.forEach(exportDefinition => {
const imported = exportDefinition.global;
const importRoot = exportDefinition.module;
let importName = exportDefinition.export;
if (!reverseMapping[importRoot]) {
reverseMapping[importRoot] = {};
}
reverseMapping[importRoot][importName] = imported;
});
return {
name: 'ember-modules-api-polyfill',
visitor: {
ImportDeclaration(path, state) {
let blacklist = (state.opts && state.opts.blacklist) || [];
'use strict'
const alfy = require('alfy')
const mapping = require('ember-rfc176-data')
function isDefaultExport(localName) {
return !!localName
}
const pairs = mapping.map(
({ global, module, export: exportName, localName, deprecated }) => {
if (isDefaultExport(localName)) {
return {
key: localName,
value: `import ${localName} from '${module}'`
}
}
return {
key: exportName,
value: `import { ${exportName} } from '${module}'`
}
}
)
const matches = alfy.inputMatches(pairs, 'key')