Skip to content

Symlink and path resolution#101

Merged
dop251 merged 2 commits intomasterfrom
symlink-resolution
Mar 14, 2025
Merged

Symlink and path resolution#101
dop251 merged 2 commits intomasterfrom
symlink-resolution

Conversation

@dop251
Copy link
Copy Markdown
Owner

@dop251 dop251 commented Mar 5, 2025

  • Added PathResolver interface, implemented a default one that does symlink resolution.
  • Most path operations are now done in the OS semantics (i.e. using filepath/path).

Fixes #83

…link resolution. Most path operations are now done in the OS semantics (i.e. using filepath/path).
Comment thread require/resolve.go
const NodePrefix = "node:"

func (r *RequireModule) resolvePath(base, name string) string {
if r.r.pathResolver != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you could change the constructor to default to the DefaultPathResolver instead of checking this every time. e.g.

func NewRegistry(opts ...Option) *Registry {
	r := &Registry{
           pathResolver : DefaultPathResolver
        }
        ...

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This would break the use of zero-value Registry. A similar mechanism is already implemented for SourceLoader.

# Conflicts:
#	go.mod
#	go.sum
@dop251 dop251 merged commit c55ecee into master Mar 14, 2025
16 checks passed
@dop251 dop251 deleted the symlink-resolution branch April 9, 2025 16:25
benallfree pushed a commit to benallfree/goja_nodejs that referenced this pull request May 3, 2025
…link resolution. Most path operations are now done in the OS semantics (i.e. using filepath/path). (dop251#101)
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.

Require lacks support for absolute paths

2 participants