8000 chore(build): fix esm-check errors · Kitware/vtk-js@0409186 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0409186

Browse files
committed
chore(build): fix esm-check errors
1 parent 6c58f6f commit 0409186

File tree

4 files changed

+44
-12
lines changed

4 files changed

+44
-12
lines changed

Utilities/build/rewrite-imports.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = (code, replaceFunc) => {
77
importRegex.lastIndex++;
88
}
99

10-
if (m[1].startsWith('../') || m[1].startsWith('./')) {
10+
if (m[1] === '..' || m[1].startsWith('../') || m[1].startsWith('./')) {
1111
const importPath = replaceFunc(m[1]);
1212
const origLen = code.length;
1313
code = code.replace(m[0], `from '${importPath}'`);

package-lock.json

Lines changed: 26 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"@rollup/plugin-eslint": "8.0.2",
6363
"@rollup/plugin-json": "4.1.0",
6464
"@rollup/plugin-node-resolve": "13.1.3",
65+
"@types/node": "^22.13.1",
6566
"autoprefixer": "10.4.7",
6667
"babel-loader": "8.2.5",
6768
"babel-plugin-istanbul": "6.1.1",
@@ -235,4 +236,4 @@
235236
"publishConfig": {
236237
"access": "public"
237238
}
238-
}
239+
}

rollup.config.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,26 @@ export default {
183183
return relatifyImports(content.toString(), (relImport) => {
184184
let importPath = relImport;
185185
const baseName = path.basename(base);
186+
const baseDir = path.dirname(base);
186187

187188
if (
188-
baseName === 'index.d.ts' &&
189-
path.dirname(base) !== 'Sources' &&
190-
(importPath.startsWith('../') || importPath.startsWith('./'))
189+
baseName !== 'index.d.ts' ||
190+
path.dirname(base) === 'Sources'
191+
) {
192+
return importPath;
193+
}
194+
195+
// implicity imports ../index.d.ts -> ../<parent_dir_name>.d.ts
196+
if (importPath === '..') {
197+
return `../${path.basename(path.dirname(baseDir))}`;
198+
}
199+
200+
if (
201+
importPath.startsWith('../') ||
202+
importPath.startsWith('./')
191203
) {
192204
// this file will be moved up one folder, so
193205
// all of its relative imports must be adjusted.
194-
const baseDir = path.dirname(base);
195206
const resolvedImportPath = path.resolve(
196207
`${baseDir}/${importPath}`
197208
);

0 commit comments

Comments
 (0)
0