@awsless/ts-file-cache 0.0.13 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -143,15 +143,16 @@ var generateRecursiveFileHashes = async (workspace, file, sourceFile, allowedExt
143
143
  }
144
144
  return;
145
145
  }
146
- if (hashes.has(file)) {
146
+ const module2 = getPackageName(file);
147
+ if (hashes.has(module2)) {
147
148
  return;
148
149
  }
149
- const dependency = findDependency(workspace, file, sourceFile);
150
+ const dependency = findDependency(workspace, module2, sourceFile);
150
151
  if (dependency) {
151
152
  if (dependency.type === "package") {
152
- hashes.set(file, Buffer.from(`${file}:${dependency.version}`, "utf8"));
153
+ hashes.set(module2, Buffer.from(`${module2}:${dependency.version}`, "utf8"));
153
154
  } else {
154
- const localPackage = workspace.packages[file];
155
+ const localPackage = workspace.packages[module2];
155
156
  if (!localPackage) {
156
157
  throw new Error(`Can't find the local workspace package for: ${file}`);
157
158
  }
@@ -168,7 +169,7 @@ var generateRecursiveFileHashes = async (workspace, file, sourceFile, allowedExt
168
169
  }
169
170
  return;
170
171
  }
171
- if (import_node_module.builtinModules.includes(file.replace(/^node\:/, ""))) {
172
+ if (import_node_module.builtinModules.includes(module2.replace(/^node\:/, ""))) {
172
173
  return;
173
174
  }
174
175
  throw new Error(`Can't find the dependency version for: ${file} inside the source: ${sourceFile}`);
@@ -177,6 +178,17 @@ var mergeHashes = (hashes) => {
177
178
  const merge = Buffer.concat(Array.from(hashes.values()).sort());
178
179
  return (0, import_crypto.createHash)("sha1").update(merge).digest("hex");
179
180
  };
181
+ var getPackageName = (importee) => {
182
+ const parts = importee.split("/");
183
+ if (importee.startsWith("@")) {
184
+ if (parts.length >= 2) {
185
+ return `${parts[0]}/${parts[1]}`;
186
+ }
187
+ } else if (parts.length >= 1) {
188
+ return parts[0];
189
+ }
190
+ throw new Error(`Malformed importee: ${importee}`);
191
+ };
180
192
  var findDependency = (workspace, module2, source) => {
181
193
  const pkg = Object.values(workspace.packages).filter((p) => source.startsWith(p.path)).sort((a, b) => b.path.split("/").length - a.path.split("/").length).find((p) => p.dependencies[module2]);
182
194
  if (!pkg) {
package/dist/index.js CHANGED
@@ -117,15 +117,16 @@ var generateRecursiveFileHashes = async (workspace, file, sourceFile, allowedExt
117
117
  }
118
118
  return;
119
119
  }
120
- if (hashes.has(file)) {
120
+ const module = getPackageName(file);
121
+ if (hashes.has(module)) {
121
122
  return;
122
123
  }
123
- const dependency = findDependency(workspace, file, sourceFile);
124
+ const dependency = findDependency(workspace, module, sourceFile);
124
125
  if (dependency) {
125
126
  if (dependency.type === "package") {
126
- hashes.set(file, Buffer.from(`${file}:${dependency.version}`, "utf8"));
127
+ hashes.set(module, Buffer.from(`${module}:${dependency.version}`, "utf8"));
127
128
  } else {
128
- const localPackage = workspace.packages[file];
129
+ const localPackage = workspace.packages[module];
129
130
  if (!localPackage) {
130
131
  throw new Error(`Can't find the local workspace package for: ${file}`);
131
132
  }
@@ -142,7 +143,7 @@ var generateRecursiveFileHashes = async (workspace, file, sourceFile, allowedExt
142
143
  }
143
144
  return;
144
145
  }
145
- if (builtinModules.includes(file.replace(/^node\:/, ""))) {
146
+ if (builtinModules.includes(module.replace(/^node\:/, ""))) {
146
147
  return;
147
148
  }
148
149
  throw new Error(`Can't find the dependency version for: ${file} inside the source: ${sourceFile}`);
@@ -151,6 +152,17 @@ var mergeHashes = (hashes) => {
151
152
  const merge = Buffer.concat(Array.from(hashes.values()).sort());
152
153
  return createHash("sha1").update(merge).digest("hex");
153
154
  };
155
+ var getPackageName = (importee) => {
156
+ const parts = importee.split("/");
157
+ if (importee.startsWith("@")) {
158
+ if (parts.length >= 2) {
159
+ return `${parts[0]}/${parts[1]}`;
160
+ }
161
+ } else if (parts.length >= 1) {
162
+ return parts[0];
163
+ }
164
+ throw new Error(`Malformed importee: ${importee}`);
165
+ };
154
166
  var findDependency = (workspace, module, source) => {
155
167
  const pkg = Object.values(workspace.packages).filter((p) => source.startsWith(p.path)).sort((a, b) => b.path.split("/").length - a.path.split("/").length).find((p) => p.dependencies[module]);
156
168
  if (!pkg) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/ts-file-cache",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {