Skip to content

Commit 60fb62d

Browse files
committed
fix: #92 still includes siblings in folder
Storing `dirname` erases too much information and we cant distinguish siblings. So given: ``` /folder1/ /folder1/foo.ts /folder1/bar.ts [...] /folder2/ /folder2/bat.ts [...] ``` foo.zip gets both foo and bar, and so does bar.zip, and so on. This change assumes that there may be generated files that are not listed in `buildResults`, but that they are "prefix-named", that is `foo.js` => `foo.js.map` - generalizing, we ignore here `foo.js*`
1 parent 4fe6328 commit 60fb62d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/pack.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export async function pack(this: EsbuildPlugin) {
7070

7171
// get a list of every function bundle
7272
const buildResults = this.buildResults;
73-
const bundlePathList = buildResults.map(b => path.dirname(b.bundlePath));
73+
const bundlePathList = buildResults.map(b => b.bundlePath);
7474

7575
// get a list of externals
7676
const externals = without<string>(this.buildOptions.exclude, this.buildOptions.external);
@@ -86,7 +86,7 @@ export async function pack(this: EsbuildPlugin) {
8686
buildResults.map(async ({ func, bundlePath }) => {
8787
const name = func.name;
8888

89-
const excludedFilesOrDirectory = bundlePathList.filter(p => !bundlePath.startsWith(p));
89+
const excludedFiles = bundlePathList.filter(p => !bundlePath.startsWith(p));
9090

9191
// allowed external dependencies in the final zip
9292
let depWhiteList = [];
@@ -102,15 +102,15 @@ export async function pack(this: EsbuildPlugin) {
102102

103103
// filter files
104104
const filesPathList = files.filter(({ rootPath, localPath }) => {
105-
// exclude non individual files based on file or dir path
106-
if (excludedFilesOrDirectory.find(p => localPath.startsWith(p))) return false;
105+
// exclude non individual files based on file path (and things that look derived, e.g. foo.js => foo.js.map)
106+
if (excludedFiles.find(p => localPath.startsWith(p))) return false;
107107

108108
// exclude non whitelisted dependencies
109109
if (localPath.startsWith('node_modules')) {
110110
// if no externals is set or if the provider is google, we do not need any files from node_modules
111111
if (!hasExternals || isGoogleProvider) return false;
112112
if (
113-
// this is needed for dependencies that maps to a path (like scopped ones)
113+
// this is needed for dependencies that maps to a path (like scoped ones)
114114
!depWhiteList.find(dep => doSharePath(localPath, 'node_modules/' + dep))
115115
)
116116
return false;

0 commit comments

Comments
 (0)