stylex
stylex copied to clipboard
add esm resolver
What changed / motivation ?
I author esm and the babel plugin wasn't recognizing my imports.
Additional Context
I tested this in my app and it resolves the files now.
The package I use is pretty lenient when It comes to imports. It might be able to be used instead of the other file path resolvers too.
Pre-flight checklist
- [x] I have read the contributing guidelines Contribution Guidelines
- [x] Performed a self-review of my code
Github won't let me write a comment on unchanged lines of code, but what I was planning to do was to change these lines:
for (const possiblePath of allAliases) {
try {
return require.resolve(possiblePath, {
paths: [path.dirname(sourceFilePath)],
});
} catch {}
}
to:
for (const possiblePath of allAliases) {
try {
return require.resolve(possiblePath, {
paths: [path.dirname(sourceFilePath)],
});
} catch {
try {
const resolved = esmResolve(possiblePath, {
allowImportingExtraExtensions: true,
});
if (resolved) {
return resolved;
}
} catch {}
}
}
I'll take a look later today
This looks like a good fix for the ESM problem! Thanks.