Skip to content

Commit 072e0dc

Browse files
committed
up
1 parent 07bdad1 commit 072e0dc

File tree

6 files changed

+7
-35
lines changed

6 files changed

+7
-35
lines changed

pnpm-lock.yaml

Lines changed: 1 addition & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integration/json/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('JSON', async () => {
3535
expect(bundlelessResult.default).toBe('foo1');
3636
});
3737

38-
test('bundleless preserver JSON', async () => {
38+
test('bundleless preserve JSON', async () => {
3939
const { content: bundlelessPreserveJson } = queryContent(
4040
contents.esm2!,
4141
/index\.js/,

tests/integration/json/package.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,5 @@
22
"name": "json-test",
33
"version": "1.0.0",
44
"private": true,
5-
"type": "module",
6-
"dependencies": {
7-
"buffer": "^6.0.3"
8-
},
9-
"devDependencies": {
10-
"@rsbuild/plugin-node-polyfill": "^1.3.0"
11-
}
5+
"type": "module"
126
}

tests/integration/json/rslib.config.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,7 @@ export default defineConfig({
3535
},
3636
output: {
3737
copy: [{ from: './**/*.json', context: './src' }],
38-
externals: ({ request }, callback) => {
39-
if (request?.endsWith('.json')) {
40-
callback(undefined, request);
41-
return;
42-
}
43-
44-
return callback();
45-
},
38+
externals: [/.*\.json$/],
4639
distPath: {
4740
root: './dist/bundleless-preserve-json',
4841
},

website/docs/en/guide/advanced/json-files.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ If you want JSON / YAML / TOML files to be output to the distribution directory
243243

244244
For example, the following configuration will output all JSON files in the `src` directory as-is:
245245

246-
```ts title="rslib.config.ts" {7,11-18}
246+
```ts title="rslib.config.ts" {7,11-19}
247247
export default defineConfig({
248248
lib: [
249249
{

website/docs/zh/guide/advanced/json-files.mdx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ Rslib 支持在不同的打包模式下,JSON / YAML / TOML 文件以不同的
240240

241241
例如下面的配置将会将 `src` 目录下的所有 JSON 文件按原样输出:
242242

243-
```ts title="rslib.config.ts" {7,11-18}
243+
```ts title="rslib.config.ts" {7,11-19}
244244
export default defineConfig({
245245
lib: [
246246
{
@@ -252,14 +252,7 @@ export default defineConfig({
252252
},
253253
output: {
254254
copy: [{ from: './**/*.json', context: './src' }],
255-
externals: ({ request }, callback) => {
256-
if (request?.endsWith('.json')) {
257-
callback(undefined, request);
258-
return;
259-
} else {
260-
return callback();
261-
}
262-
},
255+
externals: [/.*\.json$/],
263256
},
264257
},
265258
],

0 commit comments

Comments
 (0)