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

feat(node-resolve): Increase the support for .mjs/.cjs #1454

Closed
wants to merge 1 commit into from

Conversation

fierflame
Copy link

@fierflame fierflame commented Mar 12, 2023

Rollup Plugin Name: node-resolve

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

If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.

List any relevant issue numbers:

Description

Import .mts or .cts files in TypeScript files requires passing through .mjs or .cjs flies.

Copy link
Member

@NotWoods NotWoods left a comment

Choose a reason for hiding this comment

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

Can you add tests as well?

@fierflame
Copy link
Author

Test has already been added.

@fierflame fierflame requested review from NotWoods and removed request for tjenkinson March 13, 2023 13:31
@tada5hi
Copy link
Member

tada5hi commented Mar 20, 2023

@fierflame please fix the prettier issue

prettier -w packages/node-resolve/

Import .mts or .cts files in TypeScript files requires passing through .mjs or .cjs flies.
@fierflame
Copy link
Author

@fierflame please fix the prettier issue

prettier -w packages/node-resolve/

This commend has been run.

@tada5hi
Copy link
Member

tada5hi commented Mar 20, 2023

@fierflame please fix the prettier issue

prettier -w packages/node-resolve/

This commend has been run.

Btw. it is command not commend ^^

Comment on lines +159 to +160
['.mjs', '.mts'],
['.cjs', '.cts']
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm going to let other reviewers make the final call on this; it doesn't feel right that node-resolve should be looking for or accepting typescript files. That feels like the domain of the typescript plugin exclusively.

Copy link
Member

Choose a reason for hiding this comment

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

I am also not 100% convinced here. After all, @rollup/plugin-typescript will happily resolve .js extensions to .ts files. As a matter of fact, at least in the Rollup sources it does not seem to have problems if I rename files to use .mts extensions and import them as .mjs. So what problem are we solving here?

Copy link
Member

Choose a reason for hiding this comment

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

Based on the outcome of this we may want to revisit the lines above this which appear to be solving a similar problem

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I overlooked this. Then maybe it was node-resolve after all that allowed .ts files to be imported as .js. In that case, I guess it is only consistent to also handle the new extensions. But we should consider merging the two blocks.

@@ -0,0 +1,11 @@
// To make this very clearly TypeScript and not just CJS with a CTS extension
Copy link
Collaborator

Choose a reason for hiding this comment

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

same comment applies here

@onigoetz
Copy link

Hi, I'm looking forward to this feature. Is there anything left to validate and merge this?

@shellscape
Copy link
Collaborator

@onigoetz yes. all of the unresolved comments. please take a closer look at a PR before asking that question in the repo in the future.

@onigoetz

This comment was marked as off-topic.

@shellscape
Copy link
Collaborator

@lukastaegert what's your take on merging this as-is or requiring @fierflame to make some adjustments?

Copy link
Member

@lukastaegert lukastaegert left a comment

Choose a reason for hiding this comment

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

While the change looks good to me in general, I would still like for the new code to be merged with the block directly above. Also, that code checks if an importer is present, which also makes sense for the new code. If no importer is present, then this is an entry point and we do not want to make these checks.

@meyfa
Copy link
Contributor

meyfa commented May 13, 2023

I would still like for the new code to be merged with the block directly above.

In case it's done like this, please ensure to do it in a way that is compatible with issue #1465. See also my PR #1475 that fixes the problem in isolation, and adds a relevant test case.

@lukastaegert
Copy link
Member

This one should be completely covered by #1498. If that is not the case, feel free to reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants