Skip to content

Commit

Permalink
use "_.._" instead of ".._" for finder (#634)
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Jan 2, 2021
1 parent 5272bd9 commit 6443236
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

However, this means that the `outbase` directory is expected to contain all entry point files (even implicit entry point files from `import()` expressions). If an entry point isn't under the outbase directory then esbuild will to try to write the output file outside of the output directory, since the path of the entry point relative to `outbase` will start with `../` which is then joined to the output directory. This is unintentional. All output files are supposed to be written inside of the output directory.

This release fixes the problem by creating a directory with the name `.._` in the output directory for output file paths of entry points that are not inside the `outbase` directory. So if the previous example was bundled with an outbase directory of `temp`, the output directory will contain `out/.._/pages/home/index.js` and `out/.._/pages/about/index.js`. Doing this instead of stripping the leading `../` off the relative path is necessary to avoid collisions between different entry points with the same path suffix.
This release fixes the problem by creating a directory with the name `_.._` in the output directory for output file paths of entry points that are not inside the `outbase` directory. So if the previous example was bundled with an outbase directory of `temp`, the output directory will contain `out/_.._/pages/home/index.js` and `out/_.._/pages/about/index.js`. Doing this instead of stripping the leading `../` off the relative path is necessary to avoid collisions between different entry points with the same path suffix.

* Minification improvements

Expand Down
7 changes: 4 additions & 3 deletions internal/bundler/linker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2601,10 +2601,11 @@ func (c *linkerContext) computeChunks() []chunkInfo {
dotDotCount++
}
if dotDotCount > 0 {
// The use of ".._" here is somewhat arbitrary but it is unlikely to
// The use of "_.._" here is somewhat arbitrary but it is unlikely to
// collide with a folder named by a human and it works on Windows
// (Windows doesn't like names that end with a ".").
relDir = strings.Repeat(".._/", dotDotCount) + relDir[dotDotCount*3:]
// (Windows doesn't like names that end with a "."). And not starting
// with a "." means that it will not be hidden on Unix.
relDir = strings.Repeat("_.._/", dotDotCount) + relDir[dotDotCount*3:]
}
} else {
baseName = c.fs.Base(source.KeyPath.Text)
Expand Down
2 changes: 1 addition & 1 deletion internal/bundler/snapshots/snapshots_splitting.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TestBundlingFilesOutsideOfOutbase
---------- /out/.._/.._/.._/src/entry.js ----------
---------- /out/_.._/_.._/_.._/src/entry.js ----------
// src/entry.js
console.log("test");

Expand Down

0 comments on commit 6443236

Please sign in to comment.