Skip to content

test: add specs for node loader #4295

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

Closed

Conversation

JulienKode
Copy link
Contributor

@JulienKode JulienKode commented Apr 9, 2022

Description

The goal of this PR is to:

  • Implement basic hoisting for monorepo
  • add specs for the node loader

This add the two following spec:

  • basic import (currently pass)
  • hoisting (currently do not pass)

Current issue with relative Path

When you use Path and you are at . when you ask the parent it will not give you ../ resulting in a None state.

New approach

I do not know if this new approach is the best way to handle it as I'm new with rust.

We are now using absolute path so we can always get the parent except when we are at the root, and we are using pathdiff (which is used by rust itself rust-lang/rust#67108) to get the relative path with:

  • the path where we find the node_modules
  • the current directory

There are still a lof of unwrap in this first draft, so I might need to do some additional changes

BREAKING CHANGE:

No breaking change in terms of API

Related (if exists):

Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

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

Please use https://github.com/kdy1/swc/tree/node-resolver
You can make a PR towards it, if you prefer it

@JulienKode JulienKode changed the title test: hoisting node loader test: hoisting and basic path for node loader Apr 9, 2022
@JulienKode
Copy link
Contributor Author

JulienKode commented Apr 9, 2022

Thanks,
I'll do an update based on this PR,
I want to see the hoisting test fail on this PR to make sure the setup and specs are right

@kdy1
Copy link
Member

kdy1 commented Apr 10, 2022

Tests look good to me.

@kdy1 kdy1 marked this pull request as draft April 11, 2022 12:59
@JulienKode JulienKode changed the title test: hoisting and basic path for node loader feat: handle hoisting and add specs for node loader Apr 13, 2022
@JulienKode
Copy link
Contributor Author

close in favour of #4327

@JulienKode JulienKode closed this Apr 13, 2022
@JulienKode JulienKode changed the title feat: handle hoisting and add specs for node loader test: add specs for node loader Apr 13, 2022
@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants