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

Should subpath mapping/pattern support conditions? #1

Closed
yyx990803 opened this issue Jan 11, 2021 · 4 comments · Fixed by #2
Closed

Should subpath mapping/pattern support conditions? #1

yyx990803 opened this issue Jan 11, 2021 · 4 comments · Fixed by #2

Comments

@yyx990803
Copy link

Example:

{
  "exports": {
    ".": {
      "import": "./main.js",
      "require": "./cjs.js"
    },
    "./dir-mapped/": {
      "import": "./dir/",
      "require": "./dir-cjs/"
    }
  }
}

The docs doesn't really specify this, but I think it makes sense. /cc @MylesBorins

@lukeed
Copy link
Owner

lukeed commented Jan 11, 2021

Oh interesting. I'd never seen this but agree that it makes sense.
(I'm assuming you're referring to "./dir-mapped/" specifically.)

Just confirmed that it works in Node.js too (12.18, 14.15 – but not 12.14), so I think it was intended.
If @MylesBorins can confirm that's officially supported, I'll go ahead and implement this to maintain parity.

@yyx990803
Copy link
Author

This is the only blocker for Vite to switch to use this package - great job!

@MylesBorins
Copy link

MylesBorins commented Jan 11, 2021

Conditions were aways supported for subpath folders. v12.17.0 was the version of 12.x where we unflagged ESM, as such it can be expected that if you are using ESM unflagged today subpath folder mapping with conditions will be supported.

That said we have deprecated subpath folder mapping encouraging developers to instead use subpath patterns, which can do everything that subpath folder mapping can do and more.

Subpath patterns landed in v12.20.0 and v14.13.0.

lukeed added a commit that referenced this issue Jan 11, 2021
@lukeed lukeed closed this as completed in #2 Jan 11, 2021
lukeed added a commit that referenced this issue Jan 11, 2021
* fix: support conditions in directory mapping;

- Closes #1

* chore: update module size
@lukeed
Copy link
Owner

lukeed commented Jan 11, 2021

Thank you Myles :) Both are supported here, just to make it easy. The bit for subpath folder mapping is easy to remove at a later date.

With that confirmation, I went ahead and added this missing piece. Will publish a patch version now.
Thanks!

github-actions bot pushed a commit to okikio/resolve.imports that referenced this issue Jan 1, 2023
# 1.0.0 (2023-01-01)

### Bug Fixes

* allow conditions in directory mapping ([lukeed#2](https://github.com/okikio/resolve.imports/issues/2)) ([a881ef8](a881ef8)), closes [lukeed#1](https://github.com/okikio/resolve.imports/issues/1)
* check subpattern length correctly; ([81ae07a](81ae07a)), closes [lukeed#4](https://github.com/okikio/resolve.imports/issues/4)
* consolidate `Set` initializer ([9daed2a](9daed2a))
* ignore "import" condition when `requires` enabled ([dcff185](dcff185))
* tests ([567fde6](567fde6))
* tests ([758b7b5](758b7b5))
* throw "no conditions" error ([0fe321b](0fe321b))

### Features

* add `legacy` method for non-exports fields ([ce7ca85](ce7ca85))
* add `unsafe` option ([lukeed#13](https://github.com/okikio/resolve.imports/issues/13)) ([0b69d12](0b69d12))
* directory/subpath mapping; ([9e66106](9e66106))
* handle "browser" files object ([a1374ea](a1374ea))
* support mixed path/conditions (array) ([f74e3c5](f74e3c5))
* **types:** allow `readonly` and `const` arrays in options ([lukeed#15](https://github.com/okikio/resolve.imports/issues/15)) ([587b0ba](587b0ba))
github-actions bot pushed a commit to okikio/resolve.imports that referenced this issue Jan 1, 2023
# 1.0.0 (2023-01-01)

### Bug Fixes

* allow conditions in directory mapping ([lukeed#2](https://github.com/okikio/resolve.imports/issues/2)) ([a881ef8](a881ef8)), closes [lukeed#1](https://github.com/okikio/resolve.imports/issues/1)
* check subpattern length correctly; ([81ae07a](81ae07a)), closes [lukeed#4](https://github.com/okikio/resolve.imports/issues/4)
* consolidate `Set` initializer ([9daed2a](9daed2a))
* forgot to make pkg public ([3fa0663](3fa0663))
* ignore "import" condition when `requires` enabled ([dcff185](dcff185))
* tests ([567fde6](567fde6))
* tests ([758b7b5](758b7b5))
* throw "no conditions" error ([0fe321b](0fe321b))

### Features

* add `legacy` method for non-exports fields ([ce7ca85](ce7ca85))
* add `unsafe` option ([lukeed#13](https://github.com/okikio/resolve.imports/issues/13)) ([0b69d12](0b69d12))
* directory/subpath mapping; ([9e66106](9e66106))
* fork resolve.exports into resolve.imports for resolving subpath imports ([bd505cd](bd505cd))
* generate changelog ([bc66266](bc66266))
* handle "browser" files object ([a1374ea](a1374ea))
* support mixed path/conditions (array) ([f74e3c5](f74e3c5))
* **types:** allow `readonly` and `const` arrays in options ([lukeed#15](https://github.com/okikio/resolve.imports/issues/15)) ([587b0ba](587b0ba))
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 a pull request may close this issue.

3 participants