tsc-esm-fix
Advanced tools
Comparing version 2.10.0 to 2.11.0
{ | ||
"git": { | ||
"commitId": "7e3384bcb3165d56982ed71c67efb39122730ee2", | ||
"commitId": "c42fd556d5f94656319d9ffa69b93c4d42a9b493", | ||
"repoUrl": "https://github.com/antongolub/tsc-esm-fix", | ||
"repoName": "antongolub/tsc-esm-fix" | ||
}, | ||
"date": "2022-04-07T20:01:50.579Z" | ||
"date": "2022-04-07T20:11:48.222Z" | ||
} |
@@ -0,1 +1,13 @@ | ||
# [2.11.0](https://github.com/antongolub/tsc-esm-fix/compare/v2.10.0...v2.11.0) (2022-04-07) | ||
### Bug Fixes | ||
* search variants in local deps before node_modules ([c42fd55](https://github.com/antongolub/tsc-esm-fix/commit/c42fd556d5f94656319d9ffa69b93c4d42a9b493)) | ||
### Features | ||
* patch `require` statements ([a43b311](https://github.com/antongolub/tsc-esm-fix/commit/a43b311602e5ceca37feda1703981365920e14fe)) | ||
# [2.10.0](https://github.com/antongolub/tsc-esm-fix/compare/v2.9.1...v2.10.0) (2022-04-07) | ||
@@ -2,0 +14,0 @@ |
{ | ||
"name": "tsc-esm-fix", | ||
"version": "2.10.0", | ||
"version": "2.11.0", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("path"),require("fs"),require("fs-extra"),require("globby"),require("json5")):"function"==typeof define&&define.amd?define(["exports","path","fs","fs-extra","globby","json5"],n):n((e||self).tscEsmFix={},e.path,e.fs,e.fsExtra,e.globby,e.json5)}(this,function(e,n,r,t,o,u){function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=/*#__PURE__*/i(t),l=/*#__PURE__*/i(u);function s(){return s=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},s.apply(this,arguments)}var a=function(e){return r.readFileSync(e,{encoding:"utf8"})},f=function(e){return l.default.parse(a(e))},d=function(e){return e?Array.isArray(e)?e:[e]:[]},m=r.unlinkSync,p=function(e){return e.replace(/\\/g,"/")},g=function e(r){var t=f(r);if(t.extends){var o=e(n.resolve(n.dirname(r),t.extends));return s({},o,t,{compilerOptions:s({},o.compilerOptions,t.compilerOptions)})}return t},b={cwd:process.cwd(),tsconfig:"./tsconfig.json",filenameVar:!0,dirnameVar:!0,ext:!0,unlink:!0,debug:function(){}},v=function(e,r){return d(e).reduce(function(e,t){var o,u,i=g(n.resolve(r,t)),c=null==i||null==(o=i.compilerOptions)?void 0:o.outDir,l=null==i||null==(u=i.compilerOptions)||null==u.module.toLowerCase?void 0:u.module.toLowerCase();return c&&["es2020","es2021","es2022","esnext"].includes(l)&&e.push(c),e},[])},x=function(e,n){return e.map(function(e){return e.replace(/\.[^./\\]+$/,n)})},y=function(e,r,t,o){return e.replace(/(\sfrom |\simport[ (])(["'])([^"']+\/[^"']+)(["'])/g,function(e,u,i,c,l){return""+u+i+function(e,r,t,o){var u=n.dirname(e),i=n.resolve(o,"node_modules"),c=/^\..+\.[^./\\]+$/.test(r)?[r,r.replace(/\.[^./\\]+$/,"")]:[r];return[".js",".cjs",".mjs"].reduce(function(e,n){return c.forEach(function(r){return e.push(""+r+n,r+"/index"+n)}),e},[]).find(function(e){return t.includes(p(n.resolve(i,e)))||t.includes(p(n.resolve(u,e)))})||r}(r,c,t,o)+l})},h=function(e){return e.replace(/__dirname/g,"/file:\\/\\/(.+)\\/[^/]/.exec(import.meta.url)[1]")},j=function(e){return e.replace(/__filename/g,"/file:\\/\\/(.+)/.exec(import.meta.url)[1]")},_=function(e){return 0===e.trim().length?"\nexport {}\nexport default undefined\n":e},w=function(e,n,r,t){var o=t.dirnameVar,u=t.filenameVar,i=t.fillBlank,c=e;return t.ext&&(c=y(c,n,r,t.cwd)),o&&(c=h(c)),u&&(c=j(c)),i&&(c=_(c)),c};e.DEFAULT_FIX_OPTIONS=b,e.fix=function(e){try{var r=function(e){return s({},b,e,{debug:"function"==typeof(null==e?void 0:e.debug)?e.debug:!0===(null==e?void 0:e.debug)?console.log:b.debug})}(e),t=r.cwd,u=r.target,i=r.src,l=r.tsconfig,g=r.out,y=r.ext,h=r.debug,j=r.unlink,_=n.resolve(t,void 0===g?t:g),F=d(i),O=[].concat(d(u),v(l,t));h("debug:cwd",t),h("debug:outdir",_),h("debug:sources",F),h("debug:targets",O);var P=F.length>0?F.map(function(e){return e+"/**/*.ts"}):O.map(function(e){return e+"/**/*.js"});return Promise.resolve(o.globby(P,{cwd:t,onlyFiles:!0,absolute:!0})).then(function(e){return Promise.resolve(function(e){try{return Promise.resolve(function(e){return o.globby(["node_modules/*/package.json"],{cwd:e,onlyFiles:!0,absolute:!0}).then(function(e){return e.filter(function(e){return f(e).exports}).map(function(e){return n.basename(n.dirname(e))})})}(e)).then(function(n){return o.globby(["node_modules/**/*.(m|c)?js","!node_modules/.cache","!node_modules/.bin","!node_modules/**/node_modules"].concat(n.map(function(e){return"!node_modules/"+e})),{cwd:e,onlyFiles:!0,absolute:!0})})}catch(e){return Promise.reject(e)}}(t)).then(function(n){h("debug:external-names",n);var o="string"==typeof y?x(e,y):e;h("debug:local-names",o);var u=[].concat(n,o);o.forEach(function(n,o){var l=(i?e[o]:n).replace(p(t),p(_)),s=a(e[o]);!function(e,n){c.default.outputFileSync(e,n,{encoding:"utf8"})}(l,w(s,n,u,r)),!i&&j&&t===_&&l!==e[o]&&m(e[o])})})})}catch(e){return Promise.reject(e)}},e.fixBlankFiles=_,e.fixContents=w,e.fixDirnameVar=h,e.fixFilenameExtensions=x,e.fixFilenameVar=j,e.fixModuleReferences=y}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("path"),require("fs"),require("fs-extra"),require("globby"),require("json5")):"function"==typeof define&&define.amd?define(["exports","path","fs","fs-extra","globby","json5"],n):n((e||self).tscEsmFix={},e.path,e.fs,e.fsExtra,e.globby,e.json5)}(this,function(e,n,r,t,o,u){function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=/*#__PURE__*/i(t),l=/*#__PURE__*/i(u);function s(){return s=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},s.apply(this,arguments)}var f=function(e){return r.readFileSync(e,{encoding:"utf8"})},a=function(e){return l.default.parse(f(e))},d=function(e){return e?Array.isArray(e)?e:[e]:[]},m=r.unlinkSync,p=function(e){return e.replace(/\\/g,"/")},g=function e(r){var t=a(r);if(t.extends){var o=e(n.resolve(n.dirname(r),t.extends));return s({},o,t,{compilerOptions:s({},o.compilerOptions,t.compilerOptions)})}return t},b={cwd:process.cwd(),tsconfig:"./tsconfig.json",filenameVar:!0,dirnameVar:!0,ext:!0,unlink:!0,debug:function(){}},v=function(e,r){return d(e).reduce(function(e,t){var o,u,i=g(n.resolve(r,t)),c=null==i||null==(o=i.compilerOptions)?void 0:o.outDir,l=null==i||null==(u=i.compilerOptions)||null==u.module.toLowerCase?void 0:u.module.toLowerCase();return c&&l.startsWith("es")&&e.push(c),e},[])},x=function(e,n){return e.map(function(e){return e.replace(/\.[^./\\]+$/,n)})},y=function(e,r,t,o){return e.replace(/(\sfrom\s|[\s(](?:import|require)[ (])(["'])([^"']+\/[^"']+)(["'])/g,function(e,u,i,c,l){return""+u+i+function(e,r,t,o){var u=n.dirname(e),i=n.resolve(o,"node_modules"),c=/^\..+\.[^./\\]+$/.test(r)?[r,r.replace(/\.[^./\\]+$/,"")]:[r],l=[".js",".cjs",".mjs"].reduce(function(e,n){return c.forEach(function(r){return e.push(""+r+n,r+"/index"+n)}),e},[]);return l.find(function(e){return t.includes(p(n.resolve(u,e)))})||l.find(function(e){return t.includes(p(n.resolve(i,e)))})||r}(r,c,t,o)+l})},h=function(e){return e.replace(/__dirname/g,"/file:\\/\\/(.+)\\/[^/]/.exec(import.meta.url)[1]")},j=function(e){return e.replace(/__filename/g,"/file:\\/\\/(.+)/.exec(import.meta.url)[1]")},_=function(e){return 0===e.trim().length?"\nexport {}\nexport default undefined\n":e},w=function(e,n,r,t){var o=t.dirnameVar,u=t.filenameVar,i=t.fillBlank,c=e;return t.ext&&(c=y(c,n,r,t.cwd)),o&&(c=h(c)),u&&(c=j(c)),i&&(c=_(c)),c};e.DEFAULT_FIX_OPTIONS=b,e.fix=function(e){try{var r=function(e){return s({},b,e,{debug:"function"==typeof(null==e?void 0:e.debug)?e.debug:!0===(null==e?void 0:e.debug)?console.log:b.debug})}(e),t=r.cwd,u=r.target,i=r.src,l=r.tsconfig,g=r.out,y=r.ext,h=r.debug,j=r.unlink,_=n.resolve(t,void 0===g?t:g),F=d(i),O=[].concat(d(u),v(l,t));h("debug:cwd",t),h("debug:outdir",_),h("debug:sources",F),h("debug:targets",O);var P=F.length>0?F.map(function(e){return e+"/**/*.ts"}):O.map(function(e){return e+"/**/*.js"});return Promise.resolve(o.globby(P,{cwd:t,onlyFiles:!0,absolute:!0})).then(function(e){return Promise.resolve(function(e){try{return Promise.resolve(function(e){return o.globby(["node_modules/*/package.json"],{cwd:e,onlyFiles:!0,absolute:!0}).then(function(e){return e.filter(function(e){return a(e).exports}).map(function(e){return n.basename(n.dirname(e))})})}(e)).then(function(n){return o.globby(["node_modules/**/*.(m|c)?js","!node_modules/.cache","!node_modules/.bin","!node_modules/**/node_modules"].concat(n.map(function(e){return"!node_modules/"+e})),{cwd:e,onlyFiles:!0,absolute:!0})})}catch(e){return Promise.reject(e)}}(t)).then(function(n){h("debug:external-names",n);var o="string"==typeof y?x(e,y):e;h("debug:local-names",o);var u=[].concat(n,o);o.forEach(function(n,o){var l=(i?e[o]:n).replace(p(t),p(_)),s=f(e[o]);!function(e,n){c.default.outputFileSync(e,n,{encoding:"utf8"})}(l,w(s,n,u,r)),!i&&j&&t===_&&l!==e[o]&&m(e[o])})})})}catch(e){return Promise.reject(e)}},e.fixBlankFiles=_,e.fixContents=w,e.fixDirnameVar=h,e.fixFilenameExtensions=x,e.fixFilenameVar=j,e.fixModuleReferences=y}); | ||
//# sourceMappingURL=tsc-esm-fix.umd.js.map |
@@ -47,3 +47,3 @@ import { Options as GlobbyOptions } from 'globby' | ||
if (outDir && ['es2020', 'es2021', 'es2022', 'esnext'].includes(module)) { | ||
if (outDir && module.startsWith('es')) { | ||
targets.push(outDir) | ||
@@ -72,7 +72,5 @@ } | ||
return ( | ||
variants.find( | ||
(f) => | ||
files.includes(unixify(resolve(nmdir, f))) || | ||
files.includes(unixify(resolve(dir, f))), | ||
) || nested | ||
variants.find((f) => files.includes(unixify(resolve(dir, f)))) || | ||
variants.find((f) => files.includes(unixify(resolve(nmdir, f)))) || | ||
nested | ||
) | ||
@@ -91,3 +89,3 @@ } | ||
contents.replace( | ||
/(\sfrom |\simport[ (])(["'])([^"']+\/[^"']+)(["'])/g, | ||
/(\sfrom\s|[\s(](?:import|require)[ (])(["'])([^"']+\/[^"']+)(["'])/g, | ||
(matched, control, q1, from, q2) => | ||
@@ -94,0 +92,0 @@ `${control}${q1}${resolveDependency( |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93022