@esbuild-kit/cjs-loader 2.2.0 → 2.3.1

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("fs"),g=require("module"),r=require("@esbuild-kit/core-utils"),u=require("get-tsconfig");function d(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var _=d(y),l=d(g);const b=/^\.{0,2}\//,S=/\.[cm]?tsx?$/,i=u.getTsconfig(),j=i==null?void 0:i.config,p=i&&u.createPathsMatcher(i),m=r.installSourceMapSupport(),c=process.versions.node.split(".").map(Number),F=c[0]>=13&&c[1]>=2||c[0]>=12&&c[1]>=20&&c[0]<13&&c[1]<0;function h(e,t){process.send&&process.send({type:"dependency",path:t});let s=_.default.readFileSync(t,"utf8");if(t.endsWith(".cjs")&&F){const o=r.transformDynamicImport(s);o&&(s=r.applySourceMap(o,t,m))}else{const o=r.transformSync(s,t,{tsconfigRaw:j});s=r.applySourceMap(o,t,m)}e._compile(s,t)}const v=l.default._extensions;[".js",".ts",".tsx",".jsx"].forEach(e=>{v[e]=h}),Object.defineProperty(v,".mjs",{value:h,enumerable:!1});const f=l.default._resolveFilename;l.default._resolveFilename=function(e,t,s,o){if(e.startsWith("node:")&&(e=e.slice(5)),p&&!b.test(e)){const n=p(e);for(const a of n)try{return f.call(this,a,t,s,o)}catch{}}if(t&&S.test(t.filename)){const n=r.resolveTsPath(e);if(n)try{return f.call(this,n,t,s,o)}catch(a){if(a.code!=="MODULE_NOT_FOUND")throw a}}return f.call(this,e,t,s,o)};
1
+ "use strict";var v=require("path"),g=require("fs"),S=require("module"),o=require("@esbuild-kit/core-utils"),i=require("get-tsconfig");function l(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var u=l(v),y=l(g),f=l(S);const T=/^\.{0,2}\//,N=/\.[cm]?tsx?$/,F=`${u.default.sep}node_modules${u.default.sep}`,a=process.env.ESBK_TSCONFIG_PATH?{path:process.env.ESBK_TSCONFIG_PATH,config:i.parseTsconfig(process.env.ESBK_TSCONFIG_PATH)}:i.getTsconfig(),P=a==null?void 0:a.config,p=a&&i.createPathsMatcher(a),m=o.installSourceMapSupport(),M=o.compareNodeVersion([13,2,0])>=0||o.compareNodeVersion([12,20,0])>=0&&o.compareNodeVersion([13,0,0])<0;function _(e,s){process.send&&process.send({type:"dependency",path:s});let t=y.default.readFileSync(s,"utf8");if(s.endsWith(".cjs")&&M){const r=o.transformDynamicImport(t);r&&(t=o.applySourceMap(r,s,m))}else{const r=o.transformSync(t,s,{tsconfigRaw:P});t=o.applySourceMap(r,s,m)}e._compile(t,s)}const h=f.default._extensions;[".js",".ts",".tsx",".jsx"].forEach(e=>{h[e]=_}),Object.defineProperty(h,".mjs",{value:_,enumerable:!1});const O=o.compareNodeVersion([16,0,0])>=0||o.compareNodeVersion([14,18,0])>=0,d=f.default._resolveFilename;f.default._resolveFilename=function(e,s,t,r){if(!O&&e.startsWith("node:")&&(e=e.slice(5)),p&&!T.test(e)&&!(s!=null&&s.filename.includes(F))){const c=p(e);for(const n of c)try{return d.call(this,n,s,t,r)}catch{}}if(s&&N.test(s.filename)){const c=o.resolveTsPath(e);if(c)try{return d.call(this,c,s,t,r)}catch(n){if(n.code!=="MODULE_NOT_FOUND")throw n}}return d.call(this,e,s,t,r)};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esbuild-kit/cjs-loader",
3
- "version": "2.2.0",
3
+ "version": "2.3.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -32,18 +32,18 @@
32
32
  "test": "node --require ./dist/index.js tests/index.ts"
33
33
  },
34
34
  "dependencies": {
35
- "@esbuild-kit/core-utils": "^2.0.0",
36
- "get-tsconfig": "^4.0.0"
35
+ "@esbuild-kit/core-utils": "^2.1.0",
36
+ "get-tsconfig": "^4.1.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@pvtnbr/eslint-config": "^0.22.0",
40
- "@types/node": "^17.0.33",
41
- "@types/semver": "^7.3.9",
42
- "eslint": "^8.15.0",
39
+ "@pvtnbr/eslint-config": "^0.26.2",
40
+ "@types/node": "^18.0.0",
41
+ "@types/semver": "^7.3.10",
42
+ "eslint": "^8.18.0",
43
43
  "execa": "^6.1.0",
44
- "get-node": "^12.1.0",
45
- "manten": "^0.1.0",
46
- "pkgroll": "^1.3.0",
44
+ "get-node": "^13.1.0",
45
+ "manten": "^0.2.1",
46
+ "pkgroll": "^1.3.1",
47
47
  "semver": "^7.3.7",
48
48
  "source-map-support": "^0.5.21",
49
49
  "typescript": "^4.7.4"
@@ -54,16 +54,7 @@
54
54
  "tests/fixtures"
55
55
  ],
56
56
  "rules": {
57
- "import/no-unresolved": "off",
58
- "@typescript-eslint/no-shadow": [
59
- "error",
60
- {
61
- "allow": [
62
- "test",
63
- "describe"
64
- ]
65
- }
66
- ]
57
+ "import/no-unresolved": "off"
67
58
  }
68
59
  }
69
60
  }