Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix (sucrase): resolve directory imports #390

Merged

Conversation

larrybotha
Copy link
Contributor

@larrybotha larrybotha commented May 12, 2020

Rollup Plugin Name: sucrase

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:

Description

Attempting to import index.ts via its directory fails:

// my-dir/index.ts
export default 'hello';

// some-other-file.ts
import hello from './my-dir'; // <= fails

This PR fixes this issue, while adhering to Node's strategy of first attempting to resolve the filename for a file named my-dir.ts, and then attempting to resolve my-dir/index.ts: https://www.typescriptlang.org/docs/handbook/module-resolution.html#how-nodejs-resolves-modules

Copy link
Collaborator

@shellscape shellscape left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for opening this PR. I'll request review from a few others. When we have two approvals, we'll merge and put it on the release schedule.

@shellscape
Copy link
Collaborator

thanks!

@shellscape shellscape merged commit 5c9fc30 into rollup:master May 14, 2020
@larrybotha larrybotha deleted the fix/sucrase-resolve-directories branch May 15, 2020 16:07
larrybotha added a commit to larrybotha/plugins that referenced this pull request May 20, 2020
# By Tiger Oakes (2) and others
# Via GitHub
* master:
  feat(wasm): Switch to TypeScript & named exports (rollup#363)
  feat(node-resolve): Add default export (rollup#361)
  fix (sucrase): resolve directory imports (rollup#390)
  docs(typescript): update readme examples (rollup#391)

# Conflicts:
#	packages/sucrase/test/snapshots/test.js.md
#	packages/sucrase/test/snapshots/test.js.snap
#	packages/sucrase/test/test.js
#	pnpm-lock.yaml
LarsDenBakker pushed a commit to LarsDenBakker/plugins that referenced this pull request Sep 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants