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

More into: https://parceljs.org/features/dependency-resolution/#package-entries #9308

Closed
damian-pastorini opened this issue Oct 11, 2023 · 2 comments
Labels

Comments

@damian-pastorini
Copy link

More into: https://parceljs.org/features/dependency-resolution/#package-entries

Parcel checks the following fields (in order):

source – If the module is behind a symlink (e.g. in a monorepo, or via npm link), then Parcel uses the source field to compile the module from source. The source field can also be used as an alias mapping if a package has multiple entry points – see Aliases below for details.
exports – Package exports, see below for details.
browser – A browser-specific version of a package. If building for a browser environment, the browser field overrides other fields. The browser field can also be used as an alias mapping if a package has multiple entry points – see Aliases below for details.
module – An ES module version of the package.

So basically, that doesn't seems to be the case, because browser comes before module in our package and Parcel does it the other way around, maybe that is the bug?

Originally posted by @damian-pastorini in #8126 (comment)

@mischnic
Copy link
Member

mischnic commented Nov 7, 2023

I'm not sure if I understood you correctly, but for these "legacy" entries (compared to exports), the order of declaration doesn't matter.

if self.fields.contains(Fields::SOURCE) {
self.fields.remove(Fields::SOURCE);
if let Some(source) = self.package.source() {
return Some((source, "source"));
}
}
if self.fields.contains(Fields::TYPES) {
self.fields.remove(Fields::TYPES);
if let Some(types) = self.package.types {
return Some((resolve_path(&self.package.path, types), "types"));
}
}
if self.fields.contains(Fields::BROWSER) {
self.fields.remove(Fields::BROWSER);
match &self.package.browser {
BrowserField::None => {}
BrowserField::String(browser) => {
return Some((resolve_path(&self.package.path, browser), "browser"))
}
BrowserField::Map(map) => {
if let Some(AliasValue::Specifier(Specifier::Relative(s))) = map.get(&Specifier::Package(
Cow::Borrowed(self.package.name),
Cow::Borrowed(""),
)) {
return Some((resolve_path(&self.package.path, s), "browser"));
}
}
}
}
if self.fields.contains(Fields::MODULE) {
self.fields.remove(Fields::MODULE);
if let Some(module) = self.package.module {
return Some((resolve_path(&self.package.path, module), "module"));
}
}
if self.fields.contains(Fields::MAIN) {
self.fields.remove(Fields::MAIN);
if let Some(main) = self.package.main {
return Some((resolve_path(&self.package.path, main), "main"));
}
}

So what behaviour are you seeing and what did you expect to happen instead?

Copy link

github-actions bot commented May 6, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.

@github-actions github-actions bot added the Stale Inactive issues label May 6, 2024
@mischnic mischnic closed this as not planned Won't fix, can't repro, duplicate, stale May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants