Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tsc-esm-fix

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsc-esm-fix - npm Package Compare versions

Comparing version 2.20.21 to 2.20.22

8

buildstamp.json
{
"date": "2023-12-31T09:37:28.221Z",
"date": "2024-01-28T17:19:24.962Z",
"git_commit_branch": "master",
"git_commit_id": "d49c67a2ef98285fa43152c11fc3c297256e6fea",
"git_commit_id": "68cd6bd955ced0b262ed3969af3d7905b76f30ae",
"git_repo_url": "https://github.com/antongolub/tsc-esm-fix",
"git_repo_name": "antongolub/tsc-esm-fix",
"ci_run_id": "7369667545",
"ci_run_url": "https://github.com/antongolub/tsc-esm-fix/actions/runs/7369667545"
"ci_run_id": "7687277561",
"ci_run_url": "https://github.com/antongolub/tsc-esm-fix/actions/runs/7687277561"
}

@@ -0,1 +1,6 @@

## [2.20.22](https://github.com/antongolub/tsc-esm-fix/compare/v2.20.21...v2.20.22) (2024-01-28)
### Fixes & improvements
* refactor: use depseek patchRefs api ([96c826a](https://github.com/antongolub/tsc-esm-fix/commit/96c826a3354ca6029fb4f44f5f32b5cfb879d9b0))
## [2.20.21](https://github.com/antongolub/tsc-esm-fix/compare/v2.20.20...v2.20.21) (2023-12-31)

@@ -2,0 +7,0 @@

{
"name": "tsc-esm-fix",
"version": "2.20.21",
"version": "2.20.22",
"private": false,

@@ -49,3 +49,3 @@ "publishConfig": {

"dependencies": {
"depseek": "^0.2.1",
"depseek": "^0.2.4",
"fs-extra": "^11.2.0",

@@ -61,3 +61,3 @@ "globby": "^13.2.2",

"@types/jest": "^29.5.11",
"@types/node": "^20.10.6",
"@types/node": "^20.11.9",
"@types/semver": "^7.5.6",

@@ -73,3 +73,3 @@ "cpy-cli": "^5.0.0",

"mkdirp": "^3.0.1",
"prettier": "^3.1.1",
"prettier": "^3.2.4",
"prettier-config-qiwi": "^2.1.2",

@@ -79,4 +79,4 @@ "rimraf": "^5.0.5",

"tempy": "^3.1.0",
"ts-jest": "^29.1.1",
"typedoc": "^0.25.4",
"ts-jest": "^29.1.2",
"typedoc": "^0.25.7",
"typescript": "^5.3.3"

@@ -83,0 +83,0 @@ },

# tsc-esm-fix
Make TS projects compatible with [esm/mjs requirements](https://nodejs.org/api/esm.html#esm_packages)
> Make TS projects compatible with [esm/mjs requirements](https://nodejs.org/api/esm.html#esm_packages)

@@ -28,2 +28,3 @@ [![CI](https://github.com/antongolub/tsc-esm-fix/workflows/CI/badge.svg)](https://github.com/antongolub/tsc-esm-fix/actions)

* [esbuild/1043](https://github.com/evanw/esbuild/issues/1043): empty output for interface files that breaks reimport.
* [TS/4433](https://github.com/microsoft/TypeScript/issues/4433): extensions in module declarations force tsconfig changes for dependent projects. See [tsc-dts-fix](https://github.com/antongolub/misc/tree/master/packages/dep/tsc-dts-fix) for details.

@@ -37,3 +38,3 @@ #### moduleResolution: nodenext

```
Moreover, if understand [TS/49271](https://github.com/microsoft/TypeScript/issues/49271) correctly, `nodenext` + pkg.json `type: module` requires `.js` extension to be added to all `.d.ts` files of **external** ESM packages too. Well, good luck with that.
Moreover, if understand [TS/49271](https://github.com/microsoft/TypeScript/issues/49271) correctly, `nodenext` + pkg.json `type: module` requires `.js` extension to be added to all `.d.ts` files of **external** ESM packages too. Well, good luck with that.

@@ -71,3 +72,3 @@ ### Solutions

### Fetching
### Install
```shell

@@ -74,0 +75,0 @@ npm i -dev tsc-esm-fix

@@ -1,2 +0,2 @@

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("node:path"),require("fs-extra"),require("json5"),require("globby"),require("node:fs"),require("depseek")):"function"==typeof define&&define.amd?define(["exports","node:path","fs-extra","json5","globby","node:fs","depseek"],n):n((e||self).tscEsmFix={},e.path,e.fsExtra,e.json5,e.globby,e.node_fs,e.depseek)}(this,function(e,n,t,r,o,i,u){function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=/*#__PURE__*/s(n),l=/*#__PURE__*/s(t),a=/*#__PURE__*/s(r);function f(){return f=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},f.apply(this,arguments)}function d(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var m=function(e){var n=e.contents;return f({},e,{contents:0===n.trim().length?"\nexport {}\nexport default undefined\n":n})},p=function(e){return f({},e,{contents:e.contents.replace(/__dirname/g,"`${process.platform === 'win32' ? '' : '/'}${/file:\\/{2,3}(.+)\\/[^/]/.exec(import.meta.url)"+(e.isSource?"!":"")+"[1]}`")})},v=function(e){return f({},e,{contents:e.contents.replace(/__filename/g,"`${process.platform === 'win32' ? '' : '/'}${/file:\\/{2,3}(.+)/.exec(import.meta.url)"+(e.isSource?"!":"")+"[1]}`")})},g=function(e){return l.default.readFileSync(e,{encoding:"utf8"})},b=function(e,n){return l.default.outputFileSync(e,n,{encoding:"utf8"})},y=function(e){return a.default.parse(g(e))},h=function(e){return e?Array.isArray(e)?e:[e]:[]},x=l.default.unlinkSync,j=function(e){return e.replace(/\\/g,"/")},P=function e(t){var r=y(t);if(r.extends){var o=e(n.resolve(n.dirname(t),r.extends));return f({},o,r,{compilerOptions:f({},o.compilerOptions,r.compilerOptions)})}return r},S=function(e){for(var n,t=e.contents,r=e.filename,o=e.filenames,i=e.options.cwd,s=e.ignore,c=0,l="",a=function(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return d(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?d(e,n):void 0}}(e))){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(u.depseekSync(t));!(n=a()).done;){var m=n.value,p=m.index,v=m.value,g=v.length,b=v.endsWith("/")?v.slice(0,-1):v,y=!b.includes("/")&&"."!==b&&".."!==b||s.includes(b)?v:w(r,b,o,i);l=l+t.slice(c,p)+y,c=p+g}return f({},e,{contents:l+=t.slice(c)})},w=function(e,t,r,o){var i=n.dirname(e),u=n.resolve(o,"node_modules"),s=/^\..+\.[^./\\]+$/.test(t)?[t,t.replace(/\.[^./\\]+$/,"")]:[t],c=[".js",".cjs",".mjs"].reduce(function(e,n){return s.forEach(function(t){return e.push(""+t+n,t+"/index"+n)}),e},[]);return c.find(function(e){return r.includes(j(n.resolve(i,e)))})||c.find(function(e){return r.includes(j(n.resolve(u,e)))})||t},M=function(e){var t=e.contents,r=e.originName,o=e.filename;return f({},e,{contents:r===o?t:t.replace("//# sourceMappingURL="+n.basename(r)+".map","//# sourceMappingURL="+n.basename(o)+".map")})},O=function(e){var n=e.contents;return f({},e,{contents:n.includes("export default")?n:n+"\nexport default undefined\n"})},_=function(e){var n=e.options,t=e;return n.ext&&(t=S(t)),n.dirnameVar&&(t=p(t)),n.filenameVar&&(t=v(t)),n.fillBlank&&(t=m(t)),n.forceDefaultExport&&(t=O(t)),n.sourceMap&&(t=M(t)),t},k=function(e,t){return h(e).reduce(function(e,r){var o,i,u=P(n.resolve(t,r)),s=null==u||null==(o=u.compilerOptions)?void 0:o.outDir,c=null==u||null==(i=u.compilerOptions)||null==i.module.toLowerCase?void 0:i.module.toLowerCase();return s&&c.startsWith("es")?e.push(s):console.warn("tsconfig should declare `outDir` and `module` type es6 or above"),e},[])},F=function(e,t){if(!t)return e;var r=t;return r.includes("*")&&(r=r.slice(0,r.indexOf("*"))).includes("/")&&(r=r.slice(0,r.lastIndexOf("/"))),n.join(e,r)},A={cwd:process.cwd(),tsconfig:"./tsconfig.json",filenameVar:!0,dirnameVar:!0,ext:!0,unlink:!0,debug:function(){}},D=function(e,n){return e.map(function(e){return e.endsWith(".d.ts")?e:e.replace(/\.[^./\\]+$/,n)})};e.DEFAULT_FIX_OPTIONS=A,e.fix=function(e){try{var t=function(e){return f({},A,e,{debug:"function"==typeof(null==e?void 0:e.debug)?e.debug:!0===(null==e?void 0:e.debug)?console.log:A.debug})}(e);return Promise.resolve(function(e){try{var t=e.cwd,r=e.target,i=e.src,u=e.tsconfig,s=e.out,l=e.ext,a=e.debug,f=c.default.resolve(t,void 0===s?t:s),d=h(i),m=[].concat(h(r),k(u,t));a("debug:cwd",t),a("debug:outdir",f),a("debug:sources",d),a("debug:targets",m);var p=d.length>0;return Promise.resolve(function(e,n,t){return o.globby(function(e,n){return e.length>0?e.map(function(e){return e.includes("*")?e:e+"/**/*.{ts,tsx}"}):n.map(function(e){return e.includes("*")?e:e+"/**/*.{js,d.ts}"})}(e,n),{cwd:t,onlyFiles:!0,absolute:!0})}(d,m,t)).then(function(e){return Promise.resolve(function(e){try{return Promise.resolve(function(e){return o.globby(["node_modules/*/package.json","node_modules/@*/*/package.json"],{cwd:e,onlyFiles:!0,absolute:!0}).then(function(e){try{return Promise.resolve(Promise.all(e.map(function(e){try{return Promise.resolve(y(e)).then(function(t){var r=t.name,i=t.exports;if(!i)return{name:r};var u=n.dirname(e),s=function(e){var n=Object.entries(e),t=function e(n){return"string"==typeof n?[n]:Object.values(n).map(e).flat(2)};return"string"!=typeof e&&Object.keys(e).some(function(e){return e.startsWith(".")})?n.map(function(e){return[e[0],t(e[1])]}):[[".",t(e)]]}(i);return Promise.resolve(Promise.all(s.map(function(e){var t=e[0];return Promise.all(e[1].map(function(e){try{return Promise.resolve(o.globby(e,{cwd:u,onlyFiles:!0,absolute:!1})).then(function(o){return o.map(function(o){return n.join(o).replace(F(".",e),F(r,t))})})}catch(e){return Promise.reject(e)}}))}))).then(function(e){return{name:r,files:e.flat(2)}})})}catch(e){return Promise.reject(e)}}))).then(function(e){return e.reduce(function(e,n){var t,r=n.name,o=n.files;return r&&e.names.push(r),o&&(t=e.files).push.apply(t,o),e},{names:[],files:[]})})}catch(e){return Promise.reject(e)}})}(e)).then(function(n){var t=n.names,r=n.files;return Promise.resolve(o.globby(["!node_modules/.cache","!node_modules/.bin","!node_modules/**/node_modules"].concat(t.map(function(e){return"!node_modules/"+e}),["node_modules/**/*.(m|c)?js"]),{cwd:e,onlyFiles:!0,absolute:!0})).then(function(e){return{cjsModules:e,esmModules:r,allPackages:t}})})}catch(e){return Promise.reject(e)}}(t)).then(function(n){var t=n.cjsModules,r=n.esmModules,o=n.allPackages;a("debug:external-cjs-modules",t),a("debug:external-esm-modules",r);var i=[].concat(r,o),u="string"==typeof l?D(e,l):e,s=[].concat(t,u),c=[].concat(t,D(e,".js"));return a("debug:local-modules",u),{outDir:f,isSource:p,ignore:i,allJsModules:c,allModules:s,_localModules:u,localModules:e}})})}catch(e){return Promise.reject(e)}}(t)).then(function(e){return Promise.resolve(function(e,n){try{var t=n.cwd,r=n.unlink,o=n.sourceMap,u=e.outDir,s=e.isSource,l=e.ignore,a=e.allJsModules,f=e.allModules,d=e.localModules;return Promise.resolve(Promise.all(e._localModules.map(function(e,m){try{var p=e.endsWith(".d.ts")?a:f,v=d[m],h=(s?v:e).replace(j(t),j(u)),P=g(v),S=_({options:n,contents:P,isSource:s,ignore:l,filename:e,filenames:p,originName:v,nextName:h});return b(h,S.contents),!s&&r&&t===u&&h!==v&&x(v),o&&function(e,n,t){if(void 0===t&&(t=!1),e!==n){var r=e+".map";if(i.existsSync(r)){var o=n+".map",u=y(r);u.file=c.default.basename(n),b(o,JSON.stringify(u)),t&&x(r)}}}(v,h,r&&t===u),Promise.resolve()}catch(e){return Promise.reject(e)}}))).then(function(){})}catch(e){return Promise.reject(e)}}(e,t)).then(function(){})})}catch(e){return Promise.reject(e)}},e.fixBlankFiles=function(e){return m({contents:e}).contents},e.fixContents=function(e,n,t,r,o,i,u){return void 0===o&&(o=n),void 0===i&&(i=!1),void 0===u&&(u=[]),_({contents:e,filename:n,filenames:t,options:r,originName:o,isSource:i,ignore:u}).contents},e.fixDefaultExport=function(e){return O({contents:e}).contents},e.fixDirnameVar=function(e,n){return p({contents:e,isSource:n}).contents},e.fixFilenameExtensions=D,e.fixFilenameVar=function(e,n){return v({contents:e,isSource:n}).contents},e.fixModuleReferences=function(e,n,t,r,o){return S({contents:e,filename:n,filenames:t,options:{cwd:r},ignore:o}).contents},e.fixSourceMapRef=function(e,n,t){return M({contents:e,originName:n,filename:t}).contents}});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("node:path"),require("fs-extra"),require("json5"),require("globby"),require("node:fs"),require("depseek")):"function"==typeof define&&define.amd?define(["exports","node:path","fs-extra","json5","globby","node:fs","depseek"],n):n((e||self).tscEsmFix={},e.path,e.fsExtra,e.json5,e.globby,e.node_fs,e.depseek)}(this,function(e,n,t,r,o,u,i){function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=/*#__PURE__*/s(n),l=/*#__PURE__*/s(t),a=/*#__PURE__*/s(r);function f(){return f=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},f.apply(this,arguments)}var d=function(e){var n=e.contents;return f({},e,{contents:0===n.trim().length?"\nexport {}\nexport default undefined\n":n})},m=function(e){return f({},e,{contents:e.contents.replace(/__dirname/g,"`${process.platform === 'win32' ? '' : '/'}${/file:\\/{2,3}(.+)\\/[^/]/.exec(import.meta.url)"+(e.isSource?"!":"")+"[1]}`")})},p=function(e){return f({},e,{contents:e.contents.replace(/__filename/g,"`${process.platform === 'win32' ? '' : '/'}${/file:\\/{2,3}(.+)/.exec(import.meta.url)"+(e.isSource?"!":"")+"[1]}`")})},g=function(e){return l.default.readFileSync(e,{encoding:"utf8"})},v=function(e,n){return l.default.outputFileSync(e,n,{encoding:"utf8"})},b=function(e){return a.default.parse(g(e))},h=function(e){return e?Array.isArray(e)?e:[e]:[]},y=l.default.unlinkSync,x=function(e){return e.replace(/\\/g,"/")},j=function e(t){var r=b(t);if(r.extends){var o=e(n.resolve(n.dirname(t),r.extends));return f({},o,r,{compilerOptions:f({},o.compilerOptions,r.compilerOptions)})}return r},P=function(e){var n=e.filename,t=e.filenames,r=e.options.cwd,o=e.ignore;return f({},e,{contents:i.patchRefs(e.contents,function(e){var u=e.endsWith("/")?e.slice(0,-1):e;return!u.includes("/")&&"."!==u&&".."!==u||o.includes(u)?e:M(n,u,t,r)})})},M=function(e,t,r,o){var u=n.dirname(e),i=n.resolve(o,"node_modules"),s=/^\..+\.[^./\\]+$/.test(t)?[t,t.replace(/\.[^./\\]+$/,"")]:[t],c=[".js",".cjs",".mjs"].reduce(function(e,n){return s.forEach(function(t){return e.push(""+t+n,t+"/index"+n)}),e},[]);return c.find(function(e){return r.includes(x(n.resolve(u,e)))})||c.find(function(e){return r.includes(x(n.resolve(i,e)))})||t},_=function(e){var t=e.contents,r=e.originName,o=e.filename;return f({},e,{contents:r===o?t:t.replace("//# sourceMappingURL="+n.basename(r)+".map","//# sourceMappingURL="+n.basename(o)+".map")})},w=function(e){var n=e.contents;return f({},e,{contents:n.includes("export default")?n:n+"\nexport default undefined\n"})},O=function(e){var n=e.options,t=e;return n.ext&&(t=P(t)),n.dirnameVar&&(t=m(t)),n.filenameVar&&(t=p(t)),n.fillBlank&&(t=d(t)),n.forceDefaultExport&&(t=w(t)),n.sourceMap&&(t=_(t)),t},S=function(e,t){return h(e).reduce(function(e,r){var o,u,i=j(n.resolve(t,r)),s=null==i||null==(o=i.compilerOptions)?void 0:o.outDir,c=null==i||null==(u=i.compilerOptions)||null==u.module.toLowerCase?void 0:u.module.toLowerCase();return s&&c.startsWith("es")?e.push(s):console.warn("tsconfig should declare `outDir` and `module` type es6 or above"),e},[])},k=function(e,t){if(!t)return e;var r=t;return r.includes("*")&&(r=r.slice(0,r.indexOf("*"))).includes("/")&&(r=r.slice(0,r.lastIndexOf("/"))),n.join(e,r)},F={cwd:process.cwd(),tsconfig:"./tsconfig.json",filenameVar:!0,dirnameVar:!0,ext:!0,unlink:!0,debug:function(){}},D=function(e,n){return e.map(function(e){return e.endsWith(".d.ts")?e:e.replace(/\.[^./\\]+$/,n)})};e.DEFAULT_FIX_OPTIONS=F,e.fix=function(e){try{var t=function(e){return f({},F,e,{debug:"function"==typeof(null==e?void 0:e.debug)?e.debug:!0===(null==e?void 0:e.debug)?console.log:F.debug})}(e);return Promise.resolve(function(e){try{var t=e.cwd,r=e.target,u=e.src,i=e.tsconfig,s=e.out,l=e.ext,a=e.debug,f=c.default.resolve(t,void 0===s?t:s),d=h(u),m=[].concat(h(r),S(i,t));a("debug:cwd",t),a("debug:outdir",f),a("debug:sources",d),a("debug:targets",m);var p=d.length>0;return Promise.resolve(function(e,n,t){return o.globby(function(e,n){return e.length>0?e.map(function(e){return e.includes("*")?e:e+"/**/*.{ts,tsx}"}):n.map(function(e){return e.includes("*")?e:e+"/**/*.{js,d.ts}"})}(e,n),{cwd:t,onlyFiles:!0,absolute:!0})}(d,m,t)).then(function(e){return Promise.resolve(function(e){try{return Promise.resolve(function(e){return o.globby(["node_modules/*/package.json","node_modules/@*/*/package.json"],{cwd:e,onlyFiles:!0,absolute:!0}).then(function(e){try{return Promise.resolve(Promise.all(e.map(function(e){try{return Promise.resolve(b(e)).then(function(t){var r=t.name,u=t.exports;if(!u)return{name:r};var i=n.dirname(e),s=function(e){var n=Object.entries(e),t=function e(n){return"string"==typeof n?[n]:Object.values(n).map(e).flat(2)};return"string"!=typeof e&&Object.keys(e).some(function(e){return e.startsWith(".")})?n.map(function(e){return[e[0],t(e[1])]}):[[".",t(e)]]}(u);return Promise.resolve(Promise.all(s.map(function(e){var t=e[0];return Promise.all(e[1].map(function(e){try{return Promise.resolve(o.globby(e,{cwd:i,onlyFiles:!0,absolute:!1})).then(function(o){return o.map(function(o){return n.join(o).replace(k(".",e),k(r,t))})})}catch(e){return Promise.reject(e)}}))}))).then(function(e){return{name:r,files:e.flat(2)}})})}catch(e){return Promise.reject(e)}}))).then(function(e){return e.reduce(function(e,n){var t,r=n.name,o=n.files;return r&&e.names.push(r),o&&(t=e.files).push.apply(t,o),e},{names:[],files:[]})})}catch(e){return Promise.reject(e)}})}(e)).then(function(n){var t=n.names,r=n.files;return Promise.resolve(o.globby(["!node_modules/.cache","!node_modules/.bin","!node_modules/**/node_modules"].concat(t.map(function(e){return"!node_modules/"+e}),["node_modules/**/*.(m|c)?js"]),{cwd:e,onlyFiles:!0,absolute:!0})).then(function(e){return{cjsModules:e,esmModules:r,allPackages:t}})})}catch(e){return Promise.reject(e)}}(t)).then(function(n){var t=n.cjsModules,r=n.esmModules,o=n.allPackages;a("debug:external-cjs-modules",t),a("debug:external-esm-modules",r);var u=[].concat(r,o),i="string"==typeof l?D(e,l):e,s=[].concat(t,i),c=[].concat(t,D(e,".js"));return a("debug:local-modules",i),{outDir:f,isSource:p,ignore:u,allJsModules:c,allModules:s,_localModules:i,localModules:e}})})}catch(e){return Promise.reject(e)}}(t)).then(function(e){return Promise.resolve(function(e,n){try{var t=n.cwd,r=n.unlink,o=n.sourceMap,i=e.outDir,s=e.isSource,l=e.ignore,a=e.allJsModules,f=e.allModules,d=e.localModules;return Promise.resolve(Promise.all(e._localModules.map(function(e,m){try{var p=e.endsWith(".d.ts")?a:f,h=d[m],j=(s?h:e).replace(x(t),x(i)),P=g(h),M=O({options:n,contents:P,isSource:s,ignore:l,filename:e,filenames:p,originName:h,nextName:j});return v(j,M.contents),!s&&r&&t===i&&j!==h&&y(h),o&&function(e,n,t){if(void 0===t&&(t=!1),e!==n){var r=e+".map";if(u.existsSync(r)){var o=n+".map",i=b(r);i.file=c.default.basename(n),v(o,JSON.stringify(i)),t&&y(r)}}}(h,j,r&&t===i),Promise.resolve()}catch(e){return Promise.reject(e)}}))).then(function(){})}catch(e){return Promise.reject(e)}}(e,t)).then(function(){})})}catch(e){return Promise.reject(e)}},e.fixBlankFiles=function(e){return d({contents:e}).contents},e.fixContents=function(e,n,t,r,o,u,i){return void 0===o&&(o=n),void 0===u&&(u=!1),void 0===i&&(i=[]),O({contents:e,filename:n,filenames:t,options:r,originName:o,isSource:u,ignore:i}).contents},e.fixDefaultExport=function(e){return w({contents:e}).contents},e.fixDirnameVar=function(e,n){return m({contents:e,isSource:n}).contents},e.fixFilenameExtensions=D,e.fixFilenameVar=function(e,n){return p({contents:e,isSource:n}).contents},e.fixModuleReferences=function(e,n,t,r,o){return P({contents:e,filename:n,filenames:t,options:{cwd:r},ignore:o}).contents},e.fixSourceMapRef=function(e,n,t){return _({contents:e,originName:n,filename:t}).contents}});
//# sourceMappingURL=tsc-esm-fix.umd.js.map
import {dirname, resolve} from 'node:path'
import {TFixer} from '../interface'
import {unixify} from '../util'
import { depseekSync } from 'depseek'
import { patchRefs } from 'depseek'
export const fixModuleReferences: TFixer = (ctx) => {
const { contents, filename, filenames, options: {cwd}, ignore } = ctx
const deps = depseekSync(contents)
let pos = 0
let _contents = ''
for (const {index, value} of deps) {
const len = value.length
const _contents = patchRefs(contents, (value) => {
const v = value.endsWith('/') ? value.slice(0, -1) : value
const _value = (v.includes('/') || v === '.' || v === '..') && !ignore.includes(v)
return (v.includes('/') || v === '.' || v === '..') && !ignore.includes(v)
? resolveDependency(filename, v, filenames, cwd)
: value
})
_contents = _contents + contents.slice(pos, index) + _value
pos = index + len
}
_contents = _contents + contents.slice(pos)
return {...ctx, contents: _contents}

@@ -25,0 +16,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc