@rsbuild/core 2.0.0-beta.2 → 2.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  (() => {
2
2
  var __webpack_modules__ = {
3
- 823: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 159: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const { HtmlWebpackChildCompiler } = __nccwpck_require__(44);
5
+ const { HtmlWebpackChildCompiler } = __nccwpck_require__(452);
6
6
  const compilerMap = new WeakMap();
7
7
  class CachedChildCompilation {
8
8
  constructor(compiler) {
@@ -311,7 +311,7 @@
311
311
  }
312
312
  module.exports = { CachedChildCompilation };
313
313
  },
314
- 44: (module) => {
314
+ 452: (module) => {
315
315
  "use strict";
316
316
  class HtmlWebpackChildCompiler {
317
317
  constructor(templates) {
@@ -480,7 +480,7 @@
480
480
  }
481
481
  module.exports = { HtmlWebpackChildCompiler };
482
482
  },
483
- 332: (module) => {
483
+ 164: (module) => {
484
484
  "use strict";
485
485
  module.exports = {};
486
486
  module.exports.none = (chunks) => chunks;
@@ -499,7 +499,7 @@
499
499
  };
500
500
  module.exports.auto = module.exports.none;
501
501
  },
502
- 755: (module) => {
502
+ 659: (module) => {
503
503
  "use strict";
504
504
  module.exports = function (err) {
505
505
  return {
@@ -523,9 +523,9 @@
523
523
  };
524
524
  };
525
525
  },
526
- 106: (module, __unused_webpack_exports, __nccwpck_require__) => {
526
+ 978: (module, __unused_webpack_exports, __nccwpck_require__) => {
527
527
  "use strict";
528
- const { AsyncSeriesWaterfallHook } = __nccwpck_require__(159);
528
+ const { AsyncSeriesWaterfallHook } = __nccwpck_require__(540);
529
529
  const htmlWebpackPluginHooksMap = new WeakMap();
530
530
  function getHtmlRspackPluginHooks(compilation) {
531
531
  let hooks = htmlWebpackPluginHooksMap.get(compilation);
@@ -549,7 +549,7 @@
549
549
  }
550
550
  module.exports = { getHtmlRspackPluginHooks };
551
551
  },
552
- 119: (module) => {
552
+ 399: (module) => {
553
553
  const voidTags = [
554
554
  "area",
555
555
  "base",
@@ -617,19 +617,19 @@
617
617
  htmlTagObjectToString,
618
618
  };
619
619
  },
620
- 86: (module, __unused_webpack_exports, __nccwpck_require__) => {
620
+ 998: (module, __unused_webpack_exports, __nccwpck_require__) => {
621
621
  "use strict";
622
622
  const promisify = __nccwpck_require__(23).promisify;
623
623
  const vm = __nccwpck_require__(154);
624
624
  const fs = __nccwpck_require__(896);
625
625
  const path = __nccwpck_require__(928);
626
- const { CachedChildCompilation } = __nccwpck_require__(823);
626
+ const { CachedChildCompilation } = __nccwpck_require__(159);
627
627
  const { createHtmlTagObject, htmlTagObjectToString, HtmlTagArray } =
628
- __nccwpck_require__(119);
629
- const prettyError = __nccwpck_require__(755);
630
- const chunkSorter = __nccwpck_require__(332);
628
+ __nccwpck_require__(399);
629
+ const prettyError = __nccwpck_require__(659);
630
+ const chunkSorter = __nccwpck_require__(164);
631
631
  const getHtmlRspackPluginHooks =
632
- __nccwpck_require__(106).getHtmlRspackPluginHooks;
632
+ __nccwpck_require__(978).getHtmlRspackPluginHooks;
633
633
  const WITH_PLACEHOLDER = "function __with_placeholder__";
634
634
  class HtmlRspackPlugin {
635
635
  constructor(userOptions = {}) {
@@ -1573,7 +1573,7 @@
1573
1573
  "use strict";
1574
1574
  module.exports = require("vm");
1575
1575
  },
1576
- 159: (__unused_webpack_module, exports) => {
1576
+ 540: (__unused_webpack_module, exports) => {
1577
1577
  "use strict";
1578
1578
  var __nested_webpack_require_18__ = {};
1579
1579
  (() => {
@@ -2443,6 +2443,6 @@
2443
2443
  }
2444
2444
  if (typeof __nccwpck_require__ !== "undefined")
2445
2445
  __nccwpck_require__.ab = __dirname + "/";
2446
- var __webpack_exports__ = __nccwpck_require__(86);
2446
+ var __webpack_exports__ = __nccwpck_require__(998);
2447
2447
  module.exports = __webpack_exports__;
2448
2448
  })();
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Pooya Parsa <pooya@pi0.io>
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.
@@ -0,0 +1,243 @@
1
+ # jiti
2
+
3
+ <!-- automd:badges color=F0DB4F bundlephobia -->
4
+
5
+ [![npm version](https://img.shields.io/npm/v/jiti?color=F0DB4F)](https://npmjs.com/package/jiti)
6
+ [![npm downloads](https://img.shields.io/npm/dm/jiti?color=F0DB4F)](https://npmjs.com/package/jiti)
7
+ [![bundle size](https://img.shields.io/bundlephobia/minzip/jiti?color=F0DB4F)](https://bundlephobia.com/package/jiti)
8
+
9
+ <!-- /automd -->
10
+
11
+ > This is the active development branch. Check out [jiti/v1](https://github.com/unjs/jiti/tree/v1) for legacy v1 docs and code.
12
+
13
+ ## 🌟 Used in
14
+
15
+ [Docusaurus](https://docusaurus.io/), [ESLint](https://github.com/eslint/eslint), [FormKit](https://formkit.com/), [Histoire](https://histoire.dev/), [Knip](https://knip.dev/), [Nitro](https://nitro.unjs.io/), [Nuxt](https://nuxt.com/), [PostCSS loader](https://github.com/webpack-contrib/postcss-loader), [Rsbuild](https://rsbuild.dev/), [Size Limit](https://github.com/ai/size-limit), [Slidev](https://sli.dev/), [Tailwindcss](https://tailwindcss.com/), [Tokenami](https://github.com/tokenami/tokenami), [UnoCSS](https://unocss.dev/), [WXT](https://wxt.dev/), [Winglang](https://www.winglang.io/), [Graphql code generator](https://the-guild.dev/graphql/codegen), [Lingui](https://lingui.dev/), [Scaffdog](https://scaff.dog/), [Storybook](https://storybook.js.org), [...UnJS ecosystem](https://unjs.io/), [...60M+ npm monthly downloads](https://npm.chart.dev/jiti), [...6M+ public repositories](https://github.com/unjs/jiti/network/dependents).
16
+
17
+ ## ✅ Features
18
+
19
+ - Seamless TypeScript and ESM syntax support for Node.js
20
+ - Seamless interoperability between ESM and CommonJS
21
+ - Asynchronous API to replace `import()`
22
+ - Synchronous API to replace `require()` (deprecated)
23
+ - Super slim and zero dependency
24
+ - Custom resolve aliases
25
+ - Smart syntax detection to avoid extra transforms
26
+ - Node.js native `require.cache` integration
27
+ - Filesystem transpile with hard disk caches
28
+ - ESM Loader support
29
+ - JSX support (opt-in)
30
+
31
+ > [!IMPORTANT]
32
+ > To enhance compatibility, jiti `>=2.1` enabled [`interopDefault`](#interopdefault) using a new Proxy method. If you migrated to `2.0.0` earlier, this might have caused behavior changes. In case of any issues during the upgrade, please [report](https://github.com/unjs/jiti/issues) so we can investigate to solve them. 🙏🏼
33
+
34
+ ## 💡 Usage
35
+
36
+ ### CLI
37
+
38
+ You can use `jiti` CLI to quickly run any script with TypeScript and native ESM support!
39
+
40
+ ```bash
41
+ npx jiti ./index.ts
42
+ ```
43
+
44
+ ### Programmatic
45
+
46
+ Initialize a jiti instance:
47
+
48
+ ```js
49
+ // ESM
50
+ import { createJiti } from "jiti";
51
+ const jiti = createJiti(import.meta.url);
52
+
53
+ // CommonJS (deprecated)
54
+ const { createJiti } = require("jiti");
55
+ const jiti = createJiti(__filename);
56
+ ```
57
+
58
+ Import (async) and resolve with ESM compatibility:
59
+
60
+ ```js
61
+ // jiti.import(id) is similar to import(id)
62
+ const mod = await jiti.import("./path/to/file.ts");
63
+
64
+ // jiti.esmResolve(id) is similar to import.meta.resolve(id)
65
+ const resolvedPath = jiti.esmResolve("./src");
66
+ ```
67
+
68
+ If you need the default export of module, you can use `jiti.import(id, { default: true })` as shortcut to `mod?.default ?? mod`.
69
+
70
+ ```js
71
+ // shortcut to mod?.default ?? mod
72
+ const modDefault = await jiti.import("./path/to/file.ts", { default: true });
73
+ ```
74
+
75
+ CommonJS (sync & deprecated):
76
+
77
+ ```js
78
+ // jiti() is similar to require(id)
79
+ const mod = jiti("./path/to/file.ts");
80
+
81
+ // jiti.resolve() is similar to require.resolve(id)
82
+ const resolvedPath = jiti.resolve("./src");
83
+ ```
84
+
85
+ You can also pass options as the second argument:
86
+
87
+ ```js
88
+ const jiti = createJiti(import.meta.url, { debug: true });
89
+ ```
90
+
91
+ ### Register global ESM loader
92
+
93
+ You can globally register jiti using [global hooks](https://nodejs.org/api/module.html#initialize). (Important: Requires Node.js > 20)
94
+
95
+ ```js
96
+ import "jiti/register";
97
+ ```
98
+
99
+ Or:
100
+
101
+ ```bash
102
+ node --import jiti/register index.ts
103
+ ```
104
+
105
+ ## 🎈 `jiti/native`
106
+
107
+ You can alias `jiti` to `jiti/native` to directly depend on runtime's [`import.meta.resolve`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta/resolve) and dynamic [`import()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) support. This allows easing up the ecosystem transition to runtime native support by giving the same API of jiti.
108
+
109
+ ## ⚙️ Options
110
+
111
+ ### `debug`
112
+
113
+ - Type: Boolean
114
+ - Default: `false`
115
+ - Environment variable: `JITI_DEBUG`
116
+
117
+ Enable verbose logging. You can use `JITI_DEBUG=1 <your command>` to enable it.
118
+
119
+ ### `fsCache`
120
+
121
+ - Type: Boolean | String
122
+ - Default: `true`
123
+ - Environment variable: `JITI_FS_CACHE`
124
+
125
+ Filesystem source cache (enabled by default)
126
+
127
+ By default (when is `true`), jiti uses `node_modules/.cache/jiti` (if exists) or `{TMP_DIR}/jiti`.
128
+
129
+ **Note:** It is recommended that this option be enabled for better performance.
130
+
131
+ ### `rebuildFsCache`
132
+
133
+ - Type: Boolean
134
+ - Default: `false`
135
+ - Environment variable: `JITI_REBUILD_FS_CACHE`
136
+
137
+ Rebuild filesystem source cache created by `fsCache`.
138
+
139
+ ### `moduleCache`
140
+
141
+ - Type: String
142
+ - Default: `true`
143
+ - Environment variable: `JITI_MODULE_CACHE`
144
+
145
+ Runtime module cache (enabled by default).
146
+
147
+ Disabling allows editing code and importing the same module multiple times.
148
+
149
+ When enabled, jiti integrates with Node.js native CommonJS cache-store.
150
+
151
+ ### `transform`
152
+
153
+ - Type: Function
154
+ - Default: Babel (lazy loaded)
155
+
156
+ Transform function. See [src/babel](./src/babel.ts) for more details
157
+
158
+ ### `sourceMaps`
159
+
160
+ - Type: Boolean
161
+ - Default `false`
162
+ - Environment variable: `JITI_SOURCE_MAPS`
163
+
164
+ Add inline source map to transformed source for better debugging.
165
+
166
+ ### `interopDefault`
167
+
168
+ - Type: Boolean
169
+ - Default: `true`
170
+ - Environment variable: `JITI_INTEROP_DEFAULT`
171
+
172
+ Jiti combines module exports with the `default` export using an internal Proxy to improve compatibility with mixed CJS/ESM usage. You can check the current implementation [here](https://github.com/unjs/jiti/blob/main/src/utils.ts#L105).
173
+
174
+ ### `alias`
175
+
176
+ - Type: Object
177
+ - Default: -
178
+ - Environment variable: `JITI_ALIAS`
179
+
180
+ You can also pass an object to the environment variable for inline config. Example: `JITI_ALIAS='{"~/*": "./src/*"}' jiti ...`.
181
+
182
+ Custom alias map used to resolve IDs.
183
+
184
+ ### `nativeModules`
185
+
186
+ - Type: Array
187
+ - Default: ['typescript']
188
+ - Environment variable: `JITI_NATIVE_MODULES`
189
+
190
+ List of modules (within `node_modules`) to always use native `require()` for them.
191
+
192
+ ### `transformModules`
193
+
194
+ - Type: Array
195
+ - Default: []
196
+ - Environment variable: `JITI_TRANSFORM_MODULES`
197
+
198
+ List of modules (within `node_modules`) to transform them regardless of syntax.
199
+
200
+ ### `importMeta`
201
+
202
+ Parent module's [`import.meta`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta) context to use for ESM resolution. (only used for `jiti/native` import).
203
+
204
+ ### `tryNative`
205
+
206
+ - Type: Boolean
207
+ - Default: Enabled if bun is detected
208
+ - Environment variable: `JITI_TRY_NATIVE`
209
+
210
+ Try to use native require and import without jiti transformations first.
211
+
212
+ ### `jsx`
213
+
214
+ - Type: Boolean | {options}
215
+ - Default: `false`
216
+ - Environment Variable: `JITI_JSX`
217
+
218
+ Enable JSX support using [`@babel/plugin-transform-react-jsx`](https://babeljs.io/docs/babel-plugin-transform-react-jsx).
219
+
220
+ See [`test/fixtures/jsx`](./test/fixtures/jsx) for framework integration examples.
221
+
222
+ ## Development
223
+
224
+ - Clone this repository
225
+ - Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`
226
+ - Install dependencies using `pnpm install`
227
+ - Run `pnpm dev`
228
+ - Run `pnpm jiti ./test/path/to/file.ts`
229
+
230
+ ## License
231
+
232
+ <!-- automd:contributors license=MIT author="pi0" -->
233
+
234
+ Published under the [MIT](https://github.com/unjs/jiti/blob/main/LICENSE) license.
235
+ Made by [@pi0](https://github.com/pi0) and [community](https://github.com/unjs/jiti/graphs/contributors) 💛
236
+ <br><br>
237
+ <a href="https://github.com/unjs/jiti/graphs/contributors">
238
+ <img src="https://contrib.rocks/image?repo=unjs/jiti" />
239
+ </a>
240
+
241
+ <!-- /automd -->
242
+
243
+ <!-- automd:with-automd -->