@esbuild-kit/cjs-loader 2.2.1 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Hiroki Osame <hiroki.osame@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -34,6 +34,15 @@ The following properties are used from `tsconfig.json` in the working directory:
34
34
  - `jsxFactory`
35
35
  - `jsxFragmentFactory`
36
36
 
37
+ #### Custom `tsconfig.json` path
38
+ By default, `tsconfig.json` will be detected from the current working directory.
39
+
40
+ To set a custom path, use the `ESBK_TSCONFIG_PATH` environment variable:
41
+
42
+ ```sh
43
+ ESBK_TSCONFIG_PATH=./path/to/tsconfig.custom.json node -r @esbuild/cjs-loader ./file.js
44
+ ```
45
+
37
46
  ### Cache
38
47
  Modules transformations are cached in the system cache directory ([`TMPDIR`](https://en.wikipedia.org/wiki/TMPDIR)). Transforms are cached by content hash so duplicate dependencies are not re-transformed.
39
48
 
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var y=require("path"),g=require("fs"),b=require("module"),r=require("@esbuild-kit/core-utils"),d=require("get-tsconfig");function i(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var p=i(y),M=i(g),f=i(b);const S=/^\.{0,2}\//,j=/\.[cm]?tsx?$/,F=`${p.default.sep}node_modules${p.default.sep}`,l=d.getTsconfig(),x=l==null?void 0:l.config,m=l&&d.createPathsMatcher(l),h=r.installSourceMapSupport(),n=process.versions.node.split(".").map(Number),P=n[0]>=13&&n[1]>=2||n[0]>=12&&n[1]>=20&&n[0]<13&&n[1]<0;function v(e,t){process.send&&process.send({type:"dependency",path:t});let s=M.default.readFileSync(t,"utf8");if(t.endsWith(".cjs")&&P){const o=r.transformDynamicImport(s);o&&(s=r.applySourceMap(o,t,h))}else{const o=r.transformSync(s,t,{tsconfigRaw:x});s=r.applySourceMap(o,t,h)}e._compile(s,t)}const _=f.default._extensions;[".js",".ts",".tsx",".jsx"].forEach(e=>{_[e]=v}),Object.defineProperty(_,".mjs",{value:v,enumerable:!1});const u=f.default._resolveFilename;f.default._resolveFilename=function(e,t,s,o){if(e.startsWith("node:")&&(e=e.slice(5)),m&&!S.test(e)&&!(t!=null&&t.filename.includes(F))){const c=m(e);for(const a of c)try{return u.call(this,a,t,s,o)}catch{}}if(t&&j.test(t.filename)){const c=r.resolveTsPath(e);if(c)try{return u.call(this,c,t,s,o)}catch(a){if(a.code!=="MODULE_NOT_FOUND")throw a}}return u.call(this,e,t,s,o)};
1
+ "use strict";var g=require("path"),S=require("fs"),y=require("module"),n=require("@esbuild-kit/core-utils"),i=require("get-tsconfig");function f(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var p=f(g),T=f(S),u=f(y);const F=/^\.{0,2}\//,P=/\.[cm]?tsx?$/,b=`${p.default.sep}node_modules${p.default.sep}`,l=process.env.ESBK_TSCONFIG_PATH?{path:process.env.ESBK_TSCONFIG_PATH,config:i.parseTsconfig(process.env.ESBK_TSCONFIG_PATH)}:i.getTsconfig(),M=l==null?void 0:l.config,m=l&&i.createPathsMatcher(l),_=n.installSourceMapSupport(),r=process.versions.node.split(".").map(Number),O=r[0]>=13&&r[1]>=2||r[0]>=12&&r[1]>=20&&r[0]<13&&r[1]<0;function v(e,s){process.send&&process.send({type:"dependency",path:s});let t=T.default.readFileSync(s,"utf8");if(s.endsWith(".cjs")&&O){const o=n.transformDynamicImport(t);o&&(t=n.applySourceMap(o,s,_))}else{const o=n.transformSync(t,s,{tsconfigRaw:M});t=n.applySourceMap(o,s,_)}e._compile(t,s)}const h=u.default._extensions;[".js",".ts",".tsx",".jsx"].forEach(e=>{h[e]=v}),Object.defineProperty(h,".mjs",{value:v,enumerable:!1});const d=u.default._resolveFilename;u.default._resolveFilename=function(e,s,t,o){if(e.startsWith("node:")&&(e=e.slice(5)),m&&!F.test(e)&&!(s!=null&&s.filename.includes(b))){const c=m(e);for(const a of c)try{return d.call(this,a,s,t,o)}catch{}}if(s&&P.test(s.filename)){const c=n.resolveTsPath(e);if(c)try{return d.call(this,c,s,t,o)}catch(a){if(a.code!=="MODULE_NOT_FOUND")throw a}}return d.call(this,e,s,t,o)};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esbuild-kit/cjs-loader",
3
- "version": "2.2.1",
3
+ "version": "2.3.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@esbuild-kit/core-utils": "^2.0.0",
36
- "get-tsconfig": "^4.0.5"
36
+ "get-tsconfig": "^4.1.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@pvtnbr/eslint-config": "^0.22.0",