migrate-barrel-imports 0.0.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +22 -18
  2. package/package.json +10 -5
package/dist/index.js CHANGED
@@ -33,6 +33,10 @@ import $cUHbR$micromatch from "micromatch";
33
33
 
34
34
 
35
35
 
36
+ // @ts-expect-error
37
+ const $1d95f64f52ade133$var$generate = (0, $cUHbR$babelgenerator).default || (0, $cUHbR$babelgenerator);
38
+ // @ts-expect-error
39
+ const $1d95f64f52ade133$var$traverse = (0, $cUHbR$babeltraverse).default || (0, $cUHbR$babeltraverse);
36
40
  /**
37
41
  * Reads and parses the package.json file for a given package path
38
42
  *
@@ -108,7 +112,7 @@ import $cUHbR$micromatch from "micromatch";
108
112
  'topLevelAwait'
109
113
  ]
110
114
  });
111
- (0, $cUHbR$babeltraverse)(ast, {
115
+ $1d95f64f52ade133$var$traverse(ast, {
112
116
  ExportNamedDeclaration (path) {
113
117
  console.log(`Found named export in ${file}`);
114
118
  // Skip exports from other files (we only want direct exports)
@@ -118,10 +122,10 @@ import $cUHbR$micromatch from "micromatch";
118
122
  }
119
123
  // Handle variable declarations with exports
120
124
  if (path.node.declaration) {
121
- if ($cUHbR$isVariableDeclaration(path.node.declaration)) {
125
+ if ((0, $cUHbR$isVariableDeclaration)(path.node.declaration)) {
122
126
  const declarations = path.node.declaration.declarations;
123
127
  const namedExports = declarations.map((d)=>{
124
- if ($cUHbR$isIdentifier(d.id)) return d.id.name;
128
+ if ((0, $cUHbR$isIdentifier)(d.id)) return d.id.name;
125
129
  return null;
126
130
  }).filter((name)=>name !== null);
127
131
  if (namedExports.length > 0) {
@@ -137,9 +141,9 @@ import $cUHbR$micromatch from "micromatch";
137
141
  }
138
142
  // Handle export specifiers
139
143
  const namedExports = path.node.specifiers.map((s)=>{
140
- if ($cUHbR$isExportSpecifier(s)) {
144
+ if ((0, $cUHbR$isExportSpecifier)(s)) {
141
145
  const exported = s.exported;
142
- return $cUHbR$isIdentifier(exported) ? exported.name : exported.value;
146
+ return (0, $cUHbR$isIdentifier)(exported) ? exported.name : exported.value;
143
147
  }
144
148
  return null;
145
149
  }).filter((name)=>name !== null);
@@ -155,7 +159,7 @@ import $cUHbR$micromatch from "micromatch";
155
159
  ExportDefaultDeclaration (path) {
156
160
  console.log(`Found default export in ${file}`);
157
161
  const exported = path.node.declaration;
158
- if ($cUHbR$isIdentifier(exported)) {
162
+ if ((0, $cUHbR$isIdentifier)(exported)) {
159
163
  console.log(`Default export name: ${exported.name}`);
160
164
  exports.push({
161
165
  source: file,
@@ -164,7 +168,7 @@ import $cUHbR$micromatch from "micromatch";
164
168
  ],
165
169
  isIgnored: isIgnored
166
170
  });
167
- } else if ($cUHbR$isFunctionDeclaration(exported) && exported.id) {
171
+ } else if ((0, $cUHbR$isFunctionDeclaration)(exported) && exported.id) {
168
172
  console.log(`Default export name: ${exported.id.name}`);
169
173
  exports.push({
170
174
  source: file,
@@ -221,7 +225,7 @@ import $cUHbR$micromatch from "micromatch";
221
225
  'jsx'
222
226
  ]
223
227
  });
224
- (0, $cUHbR$babeltraverse)(ast, {
228
+ $1d95f64f52ade133$var$traverse(ast, {
225
229
  ImportDeclaration (path) {
226
230
  const source = path.node.source.value;
227
231
  // Check for exact package import or subpath import
@@ -291,16 +295,16 @@ import $cUHbR$micromatch from "micromatch";
291
295
  });
292
296
  let modified = false;
293
297
  let importCount = 0;
294
- (0, $cUHbR$babeltraverse)(ast, {
298
+ $1d95f64f52ade133$var$traverse(ast, {
295
299
  ImportDeclaration (path) {
296
300
  if (path.node.source.value === packageName) {
297
301
  importCount++;
298
302
  console.log(`Found import from ${packageName}`);
299
303
  const specifiers = path.node.specifiers;
300
304
  const newImports = [];
301
- for (const specifier of specifiers)if ($cUHbR$isImportSpecifier(specifier)) {
305
+ for (const specifier of specifiers)if ((0, $cUHbR$isImportSpecifier)(specifier)) {
302
306
  const imported = specifier.imported;
303
- const importName = $cUHbR$isIdentifier(imported) ? imported.name : imported.value;
307
+ const importName = (0, $cUHbR$isIdentifier)(imported) ? imported.name : imported.value;
304
308
  const exportInfo = exports.find((e)=>e.exports.includes(importName));
305
309
  if (exportInfo) {
306
310
  console.log(` Found export ${importName} in ${exportInfo.source}`);
@@ -310,9 +314,9 @@ import $cUHbR$micromatch from "micromatch";
310
314
  continue;
311
315
  }
312
316
  const importPath = includeExtension ? `${packageName}/${exportInfo.source}` : `${packageName}/${exportInfo.source.replace(/\.(js|jsx|ts|tsx|mjs|cjs)$/, '')}`;
313
- newImports.push($cUHbR$importDeclaration([
314
- $cUHbR$importSpecifier(specifier.local, specifier.imported)
315
- ], $cUHbR$stringLiteral(importPath)));
317
+ newImports.push((0, $cUHbR$importDeclaration)([
318
+ (0, $cUHbR$importSpecifier)(specifier.local, specifier.imported)
319
+ ], (0, $cUHbR$stringLiteral)(importPath)));
316
320
  modified = true;
317
321
  } else console.log(` Warning: Could not find export ${importName}`);
318
322
  }
@@ -320,12 +324,12 @@ import $cUHbR$micromatch from "micromatch";
320
324
  // If there are any remaining specifiers that weren't moved to direct imports,
321
325
  // create a new import declaration for them
322
326
  const remainingSpecifiers = specifiers.filter((s)=>{
323
- if (!$cUHbR$isImportSpecifier(s)) return true;
324
- const importName = $cUHbR$isIdentifier(s.imported) ? s.imported.name : s.imported.value;
327
+ if (!(0, $cUHbR$isImportSpecifier)(s)) return true;
328
+ const importName = (0, $cUHbR$isIdentifier)(s.imported) ? s.imported.name : s.imported.value;
325
329
  const exportInfo = exports.find((e)=>e.exports.includes(importName));
326
330
  return !exportInfo || exportInfo.isIgnored;
327
331
  });
328
- if (remainingSpecifiers.length > 0) newImports.unshift($cUHbR$importDeclaration(remainingSpecifiers, $cUHbR$stringLiteral(packageName)));
332
+ if (remainingSpecifiers.length > 0) newImports.unshift((0, $cUHbR$importDeclaration)(remainingSpecifiers, (0, $cUHbR$stringLiteral)(packageName)));
329
333
  path.replaceWithMultiple(newImports);
330
334
  console.log(' Replaced import with direct imports from source files');
331
335
  }
@@ -334,7 +338,7 @@ import $cUHbR$micromatch from "micromatch";
334
338
  });
335
339
  if (modified) {
336
340
  console.log(`Writing changes to ${filePath}`);
337
- const output = (0, $cUHbR$babelgenerator)(ast, {
341
+ const output = $1d95f64f52ade133$var$generate(ast, {
338
342
  retainLines: false,
339
343
  retainFunctionParens: true
340
344
  }, content);
package/package.json CHANGED
@@ -1,8 +1,10 @@
1
1
  {
2
2
  "name": "migrate-barrel-imports",
3
- "version": "0.0.0",
3
+ "version": "1.0.0",
4
4
  "description": "A CLI tool to migrate barrel imports in JavaScript/TypeScript monorepos",
5
- "files": ["dist/"],
5
+ "files": [
6
+ "dist/"
7
+ ],
6
8
  "main": "./dist/index.js",
7
9
  "keywords": [
8
10
  "typescript",
@@ -52,7 +54,6 @@
52
54
  "@commitlint/cli": "19.8.0",
53
55
  "@commitlint/config-conventional": "19.8.0",
54
56
  "@semantic-release/changelog": "6.0.3",
55
- "@semantic-release/git": "10.0.1",
56
57
  "@types/babel__generator": "7.6.8",
57
58
  "@types/babel__traverse": "7.20.6",
58
59
  "@types/micromatch": "4.0.9",
@@ -69,8 +70,12 @@
69
70
  "author": "Martin Brandhaug",
70
71
  "license": "MIT",
71
72
  "lint-staged": {
72
- "*.{ts,json}": ["biome check --write"],
73
- "*.ts": ["tsc-files"]
73
+ "*.{ts,json}": [
74
+ "biome check --write"
75
+ ],
76
+ "*.ts": [
77
+ "tsc-files"
78
+ ]
74
79
  },
75
80
  "engines": {
76
81
  "node": ">=20"