Skip to content

Commit f737db7

Browse files
committedMar 11, 2024
chore: improve module processing
1 parent a8f34b1 commit f737db7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed
 

Diff for: ‎release/core/publish/steps/generate-tarballs.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { APPLIED_STRATEGY, Package } from '../../../utils/package';
44
import path from 'path';
55
import fs from 'fs';
66
import { Glob } from 'bun';
7-
import { getFile } from '../../../utils/json-file';
87

98
const PROJECT_ROOT = process.cwd();
109
const TARBALL_DIR = path.join(PROJECT_ROOT, 'tmp/tarballs');
@@ -176,9 +175,13 @@ async function convertFileToModule(fileData: string, relativePath: string, pkgNa
176175
lines[i] = lines[i].replace(/^declare /, '').replaceAll(' declare ', ' ');
177176
const line = lines[i];
178177

178+
if (line.includes(`import(".`) || line.includes(`import('.`)) {
179+
throw new Error(`Unhandled Dynamic Relative Import in ${relativePath}`);
180+
}
181+
179182
if (line.startsWith('import ')) {
180183
if (!line.includes(`'`)) {
181-
throw new Error(`Unhandled import in ${relativePath}`);
184+
throw new Error(`Unhandled Import in ${relativePath}`);
182185
}
183186
if (line.includes(`'.`)) {
184187
const importPath = line.match(/'([^']+)'/)![1];
@@ -190,7 +193,7 @@ async function convertFileToModule(fileData: string, relativePath: string, pkgNa
190193
// fix re-exports
191194
else if (line.startsWith('export {')) {
192195
if (!line.includes('}')) {
193-
throw new Error(`Unhandled re-export in ${relativePath}`);
196+
throw new Error(`Unhandled Re-export in ${relativePath}`);
194197
}
195198
if (line.includes(`'.`)) {
196199
const importPath = line.match(/'([^']+)'/)![1];
@@ -202,7 +205,7 @@ async function convertFileToModule(fileData: string, relativePath: string, pkgNa
202205
// fix * re-exports
203206
else if (line.startsWith('export * from')) {
204207
if (!line.includes(`'`)) {
205-
throw new Error(`Unhandled re-export in ${relativePath}`);
208+
throw new Error(`Unhandled Re-export in ${relativePath}`);
206209
}
207210
if (line.includes(`'.`)) {
208211
const importPath = line.match(/'([^']+)'/)![1];

0 commit comments

Comments
 (0)