Skip to content

Commit

Permalink
TypeScript dependency fix (#1646)
Browse files Browse the repository at this point in the history
* TS depdency fix

- if no exact match for a module (e.g. subpath import) require the correct package from file system
- closes #1645

* changelog
  • Loading branch information
foxriver76 authored Jul 23, 2024
1 parent 6eb1fc9 commit fcc225e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Executes Javascript, Typescript Scripts.
<!--
### **WORK IN PROGRESS**
-->
### **WORK IN PROGRESS**
* (foxriver76) fixed subpath imports with controller v6 (needs js-controller v6.0.9)

### 8.7.1 (2024-07-22)
* (foxriver76) load correct typings for TypeScript scripts with js-controller v6 (needs js-controller v6.0.9)

Expand Down
3 changes: 2 additions & 1 deletion lib/sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,8 @@ function sandBox(script, name, verbose, debug, context) {
return mods[md];
} else {
try {
mods[md] = require(md);
mods[md] = require(adapter.getAdapterScopedPackageIdentifier ? adapter.getAdapterScopedPackageIdentifier(md) : md);

return mods[md];
} catch (e) {
adapter.setState(`scriptProblem.${name.substring('script.js.'.length)}`, { val: true, ack: true, c: 'require' });
Expand Down
2 changes: 1 addition & 1 deletion lib/typescriptTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function resolveTypings(pkg, adapterScopedPackageName, wrapInDeclareModule) {

const packageRoot = path.dirname(packageJsonPath);
const normalizeImportPath = filename => path.normalize(
`node_modules/${pkgIncludesTypings ? '' : '@types/'}${pkg}/${path.relative(packageRoot, filename)}`
`node_modules/${pkgIncludesTypings ? adapterScopedPackageName : `@types/${pkg}`}/${path.relative(packageRoot, filename)}`
).replace(/\\/g, '/');

/** @type {Record<string, string>} */
Expand Down

0 comments on commit fcc225e

Please sign in to comment.