@esbuild-kit/cjs-loader 2.4.0 → 2.4.2

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -24,15 +24,21 @@ npm install --save-dev @esbuild-kit/cjs-loader
24
24
 
25
25
  ## Usage
26
26
 
27
- Pass `@esbuild/cjs-loader` into the [`--require`](https://nodejs.org/api/cli.html#-r---require-module) flag
27
+ Pass `@esbuild-kit/cjs-loader` into the [`--require`](https://nodejs.org/api/cli.html#-r---require-module) flag
28
28
  ```sh
29
- node -r @esbuild/cjs-loader ./file.js
29
+ node -r @esbuild-kit/cjs-loader ./file.js
30
30
  ```
31
31
 
32
32
  ### TypeScript configuration
33
33
  The following properties are used from `tsconfig.json` in the working directory:
34
- - `jsxFactory`
35
- - `jsxFragmentFactory`
34
+ - [`strict`](https://www.typescriptlang.org/tsconfig#strict): Whether to transform to strict mode
35
+ - [`jsx`](https://esbuild.github.io/api/#jsx): Whether to transform JSX
36
+ > **Warning:** When set to `preserve`, the JSX syntax will remain untransformed. To prevent Node.js from throwing a syntax error, chain another Node.js loader that can transform JSX to JS.
37
+ - [`jsxFactory`](https://esbuild.github.io/api/#jsx-factory): How to transform JSX
38
+ - [`jsxFragmentFactory`](https://esbuild.github.io/api/#jsx-fragment): How to transform JSX Fragments
39
+ - [`jsxImportSource`](https://www.typescriptlang.org/tsconfig#jsxImportSource): Where to import JSX functions from
40
+ - [`allowJs`](https://www.typescriptlang.org/tsconfig#allowJs): Whether to apply the tsconfig to JS files
41
+ - [`paths`](https://www.typescriptlang.org/tsconfig#paths): For resolving aliases
36
42
 
37
43
  #### Custom `tsconfig.json` path
38
44
  By default, `tsconfig.json` will be detected from the current working directory.
@@ -40,7 +46,7 @@ By default, `tsconfig.json` will be detected from the current working directory.
40
46
  To set a custom path, use the `ESBK_TSCONFIG_PATH` environment variable:
41
47
 
42
48
  ```sh
43
- ESBK_TSCONFIG_PATH=./path/to/tsconfig.custom.json node -r @esbuild/cjs-loader ./file.js
49
+ ESBK_TSCONFIG_PATH=./path/to/tsconfig.custom.json node -r @esbuild-kit/cjs-loader ./file.js
44
50
  ```
45
51
 
46
52
  ### Cache
@@ -49,7 +55,7 @@ Modules transformations are cached in the system cache directory ([`TMPDIR`](htt
49
55
  Set environment variable `ESBK_DISABLE_CACHE` to a truthy value to disable the cache:
50
56
 
51
57
  ```sh
52
- ESBK_DISABLE_CACHE=1 node -r @esbuild/cjs-loader ./file.js
58
+ ESBK_DISABLE_CACHE=1 node -r @esbuild-kit/cjs-loader ./file.js
53
59
  ```
54
60
 
55
61
  ## Related
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var F=require("path"),N=require("fs"),S=require("module"),r=require("@esbuild-kit/core-utils"),l=require("get-tsconfig");function f(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var m=f(F),y=f(N),d=f(S);const P=/^\.{0,2}\//,E=/\.[cm]?tsx?$/,O=`${m.default.sep}node_modules${m.default.sep}`,i=process.env.ESBK_TSCONFIG_PATH?{path:process.env.ESBK_TSCONFIG_PATH,config:l.parseTsconfig(process.env.ESBK_TSCONFIG_PATH)}:l.getTsconfig(),b=i==null?void 0:i.config,_=i&&l.createPathsMatcher(i),h=r.installSourceMapSupport(),j=r.compareNodeVersion([13,2,0])>=0||r.compareNodeVersion([12,20,0])>=0&&r.compareNodeVersion([13,0,0])<0;function v(e,s){process.send&&process.send({type:"dependency",path:s});let t=y.default.readFileSync(s,"utf8");if(s.endsWith(".cjs")&&j){const o=r.transformDynamicImport(s,t);o&&(t=h(o,s))}else{const o=r.transformSync(t,s,{tsconfigRaw:b});t=h(o,s)}e._compile(t,s)}const T=d.default._extensions;[".js",".ts",".tsx",".jsx"].forEach(e=>{T[e]=v}),Object.defineProperty(T,".mjs",{value:v,enumerable:!1});const x=r.compareNodeVersion([16,0,0])>=0||r.compareNodeVersion([14,18,0])>=0,u=d.default._resolveFilename;d.default._resolveFilename=function(e,s,t,o){if(!x&&e.startsWith("node:")&&(e=e.slice(5)),_&&!P.test(e)&&!(s!=null&&s.filename.includes(O))){const a=_(e);for(const c of a){const p=g.call(this,c,s,t,o);if(p)return p;try{return u.call(this,c,s,t,o)}catch{}}}const n=g.call(this,e,s,t,o);return n||u.call(this,e,s,t,o)};function g(e,s,t,o){const n=r.resolveTsPath(e);if(s&&E.test(s.filename)&&n)try{return u.call(this,n,s,t,o)}catch(a){const{code:c}=a;if(c!=="MODULE_NOT_FOUND"&&c!=="ERR_PACKAGE_PATH_NOT_EXPORTED")throw a}}
1
+ "use strict";var S=require("path"),y=require("fs"),P=require("module"),r=require("@esbuild-kit/core-utils"),l=require("get-tsconfig");function f(s){return s&&typeof s=="object"&&"default"in s?s:{default:s}}var d=f(S),E=f(y),u=f(P);const O=/^\.{0,2}\//,M=/\.[cm]?tsx?$/,b=`${d.default.sep}node_modules${d.default.sep}`,i=process.env.ESBK_TSCONFIG_PATH?{path:d.default.resolve(process.env.ESBK_TSCONFIG_PATH),config:l.parseTsconfig(process.env.ESBK_TSCONFIG_PATH)}:l.getTsconfig(),v=i&&l.createFilesMatcher(i),h=i&&l.createPathsMatcher(i),T=r.installSourceMapSupport(),j=r.compareNodeVersion([13,2,0])>=0||r.compareNodeVersion([12,20,0])>=0&&r.compareNodeVersion([13,0,0])<0;function F(s,e){process.send&&process.send({type:"dependency",path:e});let t=E.default.readFileSync(e,"utf8");if(e.endsWith(".cjs")&&j){const o=r.transformDynamicImport(e,t);o&&(t=T(o,e))}else{const o=r.transformSync(t,e,{tsconfigRaw:v==null?void 0:v(e)});t=T(o,e)}s._compile(t,e)}const g=u.default._extensions;[".js",".ts",".tsx",".jsx"].forEach(s=>{g[s]=F}),Object.defineProperty(g,".mjs",{value:F,enumerable:!1});const x=r.compareNodeVersion([16,0,0])>=0||r.compareNodeVersion([14,18,0])>=0,p=u.default._resolveFilename;u.default._resolveFilename=function(s,e,t,o){var c;if(!x&&s.startsWith("node:")&&(s=s.slice(5)),h&&!O.test(s)&&!((c=e==null?void 0:e.filename)!=null&&c.includes(b))){const a=h(s);for(const m of a){const _=N.call(this,m,e,t,o);if(_)return _;try{return p.call(this,m,e,t,o)}catch{}}}const n=N.call(this,s,e,t,o);return n||p.call(this,s,e,t,o)};function N(s,e,t,o){const c=r.resolveTsPath(s);if(e&&M.test(e.filename)&&c)try{return p.call(this,c,e,t,o)}catch(n){const{code:a}=n;if(a!=="MODULE_NOT_FOUND"&&a!=="ERR_PACKAGE_PATH_NOT_EXPORTED")throw n}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esbuild-kit/cjs-loader",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -27,6 +27,6 @@
27
27
  "exports": "./dist/index.js",
28
28
  "dependencies": {
29
29
  "@esbuild-kit/core-utils": "^3.0.0",
30
- "get-tsconfig": "^4.2.0"
30
+ "get-tsconfig": "^4.4.0"
31
31
  }
32
32
  }