-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Allow configuring of symlink resolve behavior #781
Comments
Similar to rollup:
the patch below allows esbuild to ignore symlink resolution:
diff --git a/cmd/esbuild/main.go b/cmd/esbuild/main.go
index da73739..4be1c55 100644
--- a/cmd/esbuild/main.go
+++ b/cmd/esbuild/main.go
@@ -27,4 +27,5 @@ var helpText = func(colors logger.Colors) string {
` + colors.Bold + `Simple options:` + colors.Default + `
--bundle Bundle all dependencies into the output files
+ --preserve-symlinks Disable symlink resolution for module lookup
--define:K=V Substitute K with V while parsing
--external:M Exclude module M from the bundle
diff --git a/internal/config/config.go b/internal/config/config.go
index c4a7362..bfa820f 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -161,4 +161,5 @@ const (
type Options struct {
Mode Mode
+ PreserveSymlinks bool
RemoveWhitespace bool
MinifyIdentifiers bool
diff --git a/internal/resolver/resolver.go b/internal/resolver/resolver.go
index 26becd3..c254030 100644
--- a/internal/resolver/resolver.go
+++ b/internal/resolver/resolver.go
@@ -769,9 +769,11 @@ func (r *resolver) dirInfoUncached(path string) *dirInfo {
// Make sure "absRealPath" is the real path of the directory (resolving any symlinks)
- if entry, ok := parentInfo.entries[base]; ok {
- if symlink := entry.Symlink(r.fs); symlink != "" {
- info.absRealPath = symlink
- } else if parentInfo.absRealPath != "" {
- info.absRealPath = r.fs.Join(parentInfo.absRealPath, base)
+ if (!r.options.PreserveSymlinks) {
+ if entry, ok := parentInfo.entries[base]; ok {
+ if symlink := entry.Symlink(r.fs); symlink != "" {
+ info.absRealPath = symlink
+ } else if parentInfo.absRealPath != "" {
+ info.absRealPath = r.fs.Join(parentInfo.absRealPath, base)
+ }
}
}
diff --git a/pkg/api/api.go b/pkg/api/api.go
index fe5b8bc..acaeb3d 100644
--- a/pkg/api/api.go
+++ b/pkg/api/api.go
@@ -245,4 +245,5 @@ type BuildOptions struct {
GlobalName string
Bundle bool
+ PreserveSymlinks bool
Splitting bool
Outfile string
diff --git a/pkg/api/api_impl.go b/pkg/api/api_impl.go
index 0a6b326..86d6f84 100644
--- a/pkg/api/api_impl.go
+++ b/pkg/api/api_impl.go
@@ -617,4 +617,5 @@ func rebuildImpl(
Banner: buildOpts.Banner,
Footer: buildOpts.Footer,
+ PreserveSymlinks: buildOpts.PreserveSymlinks,
WatchMode: buildOpts.Watch != nil,
Plugins: plugins,
diff --git a/pkg/cli/cli_impl.go b/pkg/cli/cli_impl.go
index 8ef2517..b6f93e5 100644
--- a/pkg/cli/cli_impl.go
+++ b/pkg/cli/cli_impl.go
@@ -39,4 +39,7 @@ func parseOptionsImpl(osArgs []string, buildOpts *api.BuildOptions, transformOpt
buildOpts.Bundle = true
+ case arg == "--preserve-symlinks" && buildOpts != nil:
+ buildOpts.PreserveSymlinks = true
+
case arg == "--splitting" && buildOpts != nil:
buildOpts.Splitting = true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Previously discussed in #698. Allow users to configure
esbuild
to not resolve symlinks. I've created a reproducible use case in this repo: https://github.com/ricklamers/esbuild-symlink-example.The core issue is that for symlinks that are resolved, the modules it imports have to be co-located at the symlinks's target location instead of at the location where the symlink itself is located.
Relevant quote from the previous issue:
Would be greatly appreciated, as
esbuild
is fantastic. It sets a new standard in front-end build tools.The text was updated successfully, but these errors were encountered: