Skip to content

Commit a82e7e4

Browse files
committed
feature: @putout/plugin-esm: resolve-imported-file: couple-levels-up
1 parent c7e5234 commit a82e7e4

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
__putout_processor_filesystem([
2+
"/",
3+
"/test/",
4+
"/test/server/",
5+
["/test/server/before.js", "aW1wb3J0IG1vZHVsZXMgZnJvbSAnLi4vLi4vbGliL2luZGV4LmpzJzsK"],
6+
"/lib/",
7+
["/lib/index.js", "CiAgICAgICAgZXhwb3J0IGNvbnN0IGEgPSAzOwogICAg"],
8+
"/json/",
9+
[
10+
"/package.json",
11+
"{\"main\": \"lib/index.js\"}"
12+
]
13+
]);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
__putout_processor_filesystem([
2+
'/',
3+
'/test/',
4+
'/test/server/',
5+
['/test/server/before.js', `
6+
import modules from '../..'
7+
`],
8+
'/lib/',
9+
['/lib/index.js', `
10+
export const a = 3;
11+
`],
12+
'/json/',
13+
['/package.json', '{"main": "lib/index.js"}'],
14+
]);

packages/plugin-esm/lib/resolve-imported-file/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function buildResolved(rootPath, importsTuples) {
108108
continue;
109109
}
110110

111-
if (relative === '..' || relative === '../') {
111+
if (relative.startsWith('..')) {
112112
const withPackage = join(current, 'package.json');
113113
const [packageJson] = findFile(rootPath, withPackage);
114114

packages/plugin-esm/lib/resolve-imported-file/index.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,8 @@ test('esm: resolve-imported-file: transform: dot-dot-slash', (t) => {
4141
t.transform('dot-dot-slash');
4242
t.end();
4343
});
44+
45+
test('esm: resolve-imported-file: transform: couple-levels-up', (t) => {
46+
t.transform('couple-levels-up');
47+
t.end();
48+
});

0 commit comments

Comments
 (0)