@teleporthq/teleport-plugin-import-statements
Advanced tools
Comparing version 0.32.0-alpha.0 to 0.32.0
@@ -28,3 +28,3 @@ "use strict"; | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -63,10 +63,10 @@ if (y = 0, t) op = [op[0] & 2, t.value]; | ||
_a = uidl.importDefinitions, importDefinitions_1 = _a === void 0 ? {} : _a; | ||
collectedDependencies = __assign(__assign({}, collectedDependencies), importDefinitions_1); | ||
if (Object.keys(importDefinitions_1).length > 0) { | ||
Object.keys(importDefinitions_1).forEach(function (dependencyRef) { | ||
var _a, _b, _c, _d, _e, _f; | ||
var _a, _b, _c, _d, _e, _f, _g; | ||
var dependency = importDefinitions_1[dependencyRef]; | ||
if (((_a = dependency.meta) === null || _a === void 0 ? void 0 : _a.useAsReference) || | ||
((_b = dependency.meta) === null || _b === void 0 ? void 0 : _b.importJustPath) || | ||
(dependency === null || dependency === void 0 ? void 0 : dependency.meta.needsWindowObject)) { | ||
(dependency === null || dependency === void 0 ? void 0 : dependency.meta.needsWindowObject) || | ||
(dependency === null || dependency === void 0 ? void 0 : dependency.type) === 'library') { | ||
return; | ||
@@ -76,8 +76,8 @@ } | ||
type: 'package', | ||
path: ((_c = dependency.meta) === null || _c === void 0 ? void 0 : _c.importJustPath) ? dependency.path : dependencyRef, | ||
path: ((_c = dependency.meta) === null || _c === void 0 ? void 0 : _c.importAlias) ? (_d = dependency.meta) === null || _d === void 0 ? void 0 : _d.importAlias : dependencyRef, | ||
version: dependency.version, | ||
meta: { | ||
importJustPath: (_d = dependency === null || dependency === void 0 ? void 0 : dependency.meta) === null || _d === void 0 ? void 0 : _d.importJustPath, | ||
originalName: (_e = dependency === null || dependency === void 0 ? void 0 : dependency.meta) === null || _e === void 0 ? void 0 : _e.originalName, | ||
namedImport: (_f = dependency === null || dependency === void 0 ? void 0 : dependency.meta) === null || _f === void 0 ? void 0 : _f.namedImport, | ||
importJustPath: (_e = dependency === null || dependency === void 0 ? void 0 : dependency.meta) === null || _e === void 0 ? void 0 : _e.importJustPath, | ||
originalName: (_f = dependency === null || dependency === void 0 ? void 0 : dependency.meta) === null || _f === void 0 ? void 0 : _f.originalName, | ||
namedImport: (_g = dependency === null || dependency === void 0 ? void 0 : dependency.meta) === null || _g === void 0 ? void 0 : _g.namedImport, | ||
}, | ||
@@ -87,2 +87,3 @@ }; | ||
} | ||
collectedDependencies = __assign(__assign({}, collectedDependencies), importDefinitions_1); | ||
} | ||
@@ -106,3 +107,3 @@ libraryDependencies = groupDependenciesByPackage(collectedDependencies, 'library'); | ||
.forEach(function (key) { | ||
var _a, _b, _c, _d; | ||
var _a, _b; | ||
var dep = dependencies[key]; | ||
@@ -116,12 +117,10 @@ // Should not be the case at this point | ||
} | ||
if ((_a = dep === null || dep === void 0 ? void 0 : dep.meta) === null || _a === void 0 ? void 0 : _a.importAlias) { | ||
result[dep.meta.importAlias] = []; | ||
var dependencyPath = (_b = (_a = dep === null || dep === void 0 ? void 0 : dep.meta) === null || _a === void 0 ? void 0 : _a.importAlias) !== null && _b !== void 0 ? _b : dep.path; | ||
if (!result[dependencyPath]) { | ||
result[dependencyPath] = []; | ||
} | ||
if (!((_b = dep === null || dep === void 0 ? void 0 : dep.meta) === null || _b === void 0 ? void 0 : _b.importAlias) && !result[dep.path]) { | ||
result[dep.path] = []; // Initialize the dependencies from this path | ||
} | ||
var importJustPath = (dep.meta && dep.meta.importJustPath) || false; | ||
var namedImport = !!(dep.meta && dep.meta.namedImport); | ||
var originalName = dep.meta && dep.meta.originalName ? dep.meta.originalName : key; | ||
result[(_d = (_c = dep === null || dep === void 0 ? void 0 : dep.meta) === null || _c === void 0 ? void 0 : _c.importAlias) !== null && _d !== void 0 ? _d : dep.path].push({ | ||
result[dependencyPath].push({ | ||
identifierName: key, | ||
@@ -128,0 +127,0 @@ namedImport: namedImport, |
@@ -27,3 +27,3 @@ var __assign = (this && this.__assign) || function () { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -60,10 +60,10 @@ if (y = 0, t) op = [op[0] & 2, t.value]; | ||
_a = uidl.importDefinitions, importDefinitions_1 = _a === void 0 ? {} : _a; | ||
collectedDependencies = __assign(__assign({}, collectedDependencies), importDefinitions_1); | ||
if (Object.keys(importDefinitions_1).length > 0) { | ||
Object.keys(importDefinitions_1).forEach(function (dependencyRef) { | ||
var _a, _b, _c, _d, _e, _f; | ||
var _a, _b, _c, _d, _e, _f, _g; | ||
var dependency = importDefinitions_1[dependencyRef]; | ||
if (((_a = dependency.meta) === null || _a === void 0 ? void 0 : _a.useAsReference) || | ||
((_b = dependency.meta) === null || _b === void 0 ? void 0 : _b.importJustPath) || | ||
(dependency === null || dependency === void 0 ? void 0 : dependency.meta.needsWindowObject)) { | ||
(dependency === null || dependency === void 0 ? void 0 : dependency.meta.needsWindowObject) || | ||
(dependency === null || dependency === void 0 ? void 0 : dependency.type) === 'library') { | ||
return; | ||
@@ -73,8 +73,8 @@ } | ||
type: 'package', | ||
path: ((_c = dependency.meta) === null || _c === void 0 ? void 0 : _c.importJustPath) ? dependency.path : dependencyRef, | ||
path: ((_c = dependency.meta) === null || _c === void 0 ? void 0 : _c.importAlias) ? (_d = dependency.meta) === null || _d === void 0 ? void 0 : _d.importAlias : dependencyRef, | ||
version: dependency.version, | ||
meta: { | ||
importJustPath: (_d = dependency === null || dependency === void 0 ? void 0 : dependency.meta) === null || _d === void 0 ? void 0 : _d.importJustPath, | ||
originalName: (_e = dependency === null || dependency === void 0 ? void 0 : dependency.meta) === null || _e === void 0 ? void 0 : _e.originalName, | ||
namedImport: (_f = dependency === null || dependency === void 0 ? void 0 : dependency.meta) === null || _f === void 0 ? void 0 : _f.namedImport, | ||
importJustPath: (_e = dependency === null || dependency === void 0 ? void 0 : dependency.meta) === null || _e === void 0 ? void 0 : _e.importJustPath, | ||
originalName: (_f = dependency === null || dependency === void 0 ? void 0 : dependency.meta) === null || _f === void 0 ? void 0 : _f.originalName, | ||
namedImport: (_g = dependency === null || dependency === void 0 ? void 0 : dependency.meta) === null || _g === void 0 ? void 0 : _g.namedImport, | ||
}, | ||
@@ -84,2 +84,3 @@ }; | ||
} | ||
collectedDependencies = __assign(__assign({}, collectedDependencies), importDefinitions_1); | ||
} | ||
@@ -102,3 +103,3 @@ libraryDependencies = groupDependenciesByPackage(collectedDependencies, 'library'); | ||
.forEach(function (key) { | ||
var _a, _b, _c, _d; | ||
var _a, _b; | ||
var dep = dependencies[key]; | ||
@@ -112,12 +113,10 @@ // Should not be the case at this point | ||
} | ||
if ((_a = dep === null || dep === void 0 ? void 0 : dep.meta) === null || _a === void 0 ? void 0 : _a.importAlias) { | ||
result[dep.meta.importAlias] = []; | ||
var dependencyPath = (_b = (_a = dep === null || dep === void 0 ? void 0 : dep.meta) === null || _a === void 0 ? void 0 : _a.importAlias) !== null && _b !== void 0 ? _b : dep.path; | ||
if (!result[dependencyPath]) { | ||
result[dependencyPath] = []; | ||
} | ||
if (!((_b = dep === null || dep === void 0 ? void 0 : dep.meta) === null || _b === void 0 ? void 0 : _b.importAlias) && !result[dep.path]) { | ||
result[dep.path] = []; // Initialize the dependencies from this path | ||
} | ||
var importJustPath = (dep.meta && dep.meta.importJustPath) || false; | ||
var namedImport = !!(dep.meta && dep.meta.namedImport); | ||
var originalName = dep.meta && dep.meta.originalName ? dep.meta.originalName : key; | ||
result[(_d = (_c = dep === null || dep === void 0 ? void 0 : dep.meta) === null || _c === void 0 ? void 0 : _c.importAlias) !== null && _d !== void 0 ? _d : dep.path].push({ | ||
result[dependencyPath].push({ | ||
identifierName: key, | ||
@@ -124,0 +123,0 @@ namedImport: namedImport, |
{ | ||
"name": "@teleporthq/teleport-plugin-import-statements", | ||
"version": "0.32.0-alpha.0", | ||
"version": "0.32.0", | ||
"description": "A plugin for handling import statements in JavaScript code", | ||
@@ -27,6 +27,6 @@ "author": "teleportHQ", | ||
"dependencies": { | ||
"@teleporthq/teleport-plugin-common": "^0.32.0-alpha.0", | ||
"@teleporthq/teleport-types": "^0.32.0-alpha.0" | ||
"@teleporthq/teleport-plugin-common": "^0.32.0", | ||
"@teleporthq/teleport-types": "^0.32.0" | ||
}, | ||
"gitHead": "de47527436cc4f1d00f241718fbdfdb86e616e3b" | ||
"gitHead": "08e6b6b0a6328cdbf86891871be39a377450a084" | ||
} |
@@ -36,6 +36,3 @@ import { ASTBuilders } from '@teleporthq/teleport-plugin-common' | ||
const { importDefinitions = {} } = uidl | ||
collectedDependencies = { | ||
...collectedDependencies, | ||
...importDefinitions, | ||
} | ||
if (Object.keys(importDefinitions).length > 0) { | ||
@@ -47,9 +44,11 @@ Object.keys(importDefinitions).forEach((dependencyRef) => { | ||
dependency.meta?.importJustPath || | ||
dependency?.meta.needsWindowObject | ||
dependency?.meta.needsWindowObject || | ||
dependency?.type === 'library' | ||
) { | ||
return | ||
} | ||
dependencies[dependencyRef] = { | ||
type: 'package', | ||
path: dependency.meta?.importJustPath ? dependency.path : dependencyRef, | ||
path: dependency.meta?.importAlias ? dependency.meta?.importAlias : dependencyRef, | ||
version: dependency.version, | ||
@@ -64,2 +63,7 @@ meta: { | ||
} | ||
collectedDependencies = { | ||
...collectedDependencies, | ||
...importDefinitions, | ||
} | ||
} | ||
@@ -70,2 +74,3 @@ | ||
const localDependencies = groupDependenciesByPackage(collectedDependencies, 'local') | ||
addImportChunk(structure.chunks, libraryDependencies, importLibsChunkName, fileType) | ||
@@ -100,10 +105,7 @@ addImportChunk(structure.chunks, packageDependencies, importPackagesChunkName, fileType) | ||
if (dep?.meta?.importAlias) { | ||
result[dep.meta.importAlias] = [] | ||
const dependencyPath = dep?.meta?.importAlias ?? dep.path | ||
if (!result[dependencyPath]) { | ||
result[dependencyPath] = [] | ||
} | ||
if (!dep?.meta?.importAlias && !result[dep.path]) { | ||
result[dep.path] = [] // Initialize the dependencies from this path | ||
} | ||
const importJustPath = (dep.meta && dep.meta.importJustPath) || false | ||
@@ -113,3 +115,3 @@ const namedImport = !!(dep.meta && dep.meta.namedImport) | ||
result[dep?.meta?.importAlias ?? dep.path].push({ | ||
result[dependencyPath].push({ | ||
identifierName: key, | ||
@@ -116,0 +118,0 @@ namedImport, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
86656
465