Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! loader: return package format from defaul…
Browse files Browse the repository at this point in the history
…tResolve if known
  • Loading branch information
dygabo committed Dec 4, 2021
1 parent 022a2eb commit 33a4572
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions test/es-module/test-esm-resolve-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const {

const rel = (file) => path.join(tmpdir.path, file);
const previousCwd = process.cwd();
const nmDir = rel('node_modules');
try {
tmpdir.refresh();
process.chdir(tmpdir.path);
Expand Down Expand Up @@ -60,7 +61,6 @@ try {
}
};

const nmDir = rel('node_modules');
const mDir = rel(`node_modules/${moduleName}`);
const subDir = rel(`node_modules/${moduleName}/subdir`);
const pkg = rel(`node_modules/${moduleName}/package.json`);
Expand All @@ -80,11 +80,7 @@ try {
const resolveResult = resolve(`${moduleName}`);
assert.strictEqual(resolveResult.format, expectedResolvedType);

fs.unlinkSync(script);
fs.unlinkSync(pkg);
fs.rmdirSync(subDir);
fs.rmdirSync(mDir);
fs.rmdirSync(nmDir);
fs.rmSync(nmDir, { recursive: true, force: true });
});
})().then(common.mustCall());

Expand Down Expand Up @@ -134,7 +130,6 @@ try {

const moduleName = 'my-dual-package';

const nmDir = rel('node_modules');
const mDir = rel(`node_modules/${moduleName}`);
const esSubDir = rel(`node_modules/${moduleName}/es`);
const cjsSubDir = rel(`node_modules/${moduleName}/lib`);
Expand Down Expand Up @@ -172,21 +167,11 @@ try {
esm-resolve-tester: () => {return 42}}`
);


// test the resolve
const resolveResult = resolve(`${moduleName}`);
assert.strictEqual(resolveResult.format, 'module');
assert.ok(resolveResult.url.includes('my-dual-package/es/index.js'));

// cleanup
fs.unlinkSync(esScript);
fs.unlinkSync(cjsScript);
fs.unlinkSync(pkg);
fs.unlinkSync(esmPkg);
fs.rmdirSync(esSubDir);
fs.rmdirSync(cjsSubDir);
fs.rmdirSync(mDir);
fs.rmdirSync(nmDir);
} finally {
process.chdir(previousCwd);
fs.rmSync(nmDir, { recursive: true, force: true });
}

0 comments on commit 33a4572

Please sign in to comment.