Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/solid-birds-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lynx-js/rspeedy": patch
---

The default value of `output.inlineScripts` should be `true`.
2 changes: 2 additions & 0 deletions packages/rspeedy/core/src/config/rsbuild/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export function toRsbuildConfig(

filenameHash: config.output?.filenameHash,

inlineScripts: config.output?.inlineScripts,

// TODO(OSS): change the default value to `linked`(or `undefined`) when OSS.
// We expect to use different default legalComments with Rsbuild
legalComments: config.output?.legalComments ?? 'none',
Expand Down
57 changes: 57 additions & 0 deletions packages/rspeedy/core/test/config/output/inline-scripts.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
import type { RsbuildPluginAPI } from '@rsbuild/core'
import { describe, expect, test } from 'vitest'

import { createStubRspeedy } from '../../createStubRspeedy.js'

describe('output.inlineScripts', () => {
test('defaults', async () => {
const rspeedy = await createStubRspeedy({
plugins: [
{
name: 'test',
setup(api: RsbuildPluginAPI) {
api.modifyRsbuildConfig((config) => {
expect(config.output?.inlineScripts).toBe(true)
})
api.modifyBundlerChain((_, { environment }) => {
expect(environment.config.output.inlineScripts).toBe(true)
})
},
},
],
})

await rspeedy.initConfigs()

expect.assertions(2)
})

test('output.inlineScripts: false', async () => {
const rspeedy = await createStubRspeedy({
output: {
inlineScripts: false,
},

plugins: [
{
name: 'test',
setup(api: RsbuildPluginAPI) {
api.modifyRsbuildConfig((config) => {
expect(config.output?.inlineScripts).toBe(false)
})
api.modifyBundlerChain((_, { environment }) => {
expect(environment.config.output.inlineScripts).toBe(false)
})
},
},
],
})

await rspeedy.initConfigs()

expect.assertions(2)
})
})
12 changes: 12 additions & 0 deletions packages/rspeedy/core/test/config/rsbuild.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ describe('Config - toRsBuildConfig', () => {
"dataUriLimit": 2048,
"distPath": undefined,
"filenameHash": undefined,
"inlineScripts": undefined,
"legalComments": "none",
"polyfill": "off",
"sourceMap": undefined,
Expand Down Expand Up @@ -406,6 +407,17 @@ describe('Config - toRsBuildConfig', () => {
expect(rsbuildConfig.output?.distPath?.root).toBe('foo')
})

test('transform output.inlineScripts', () => {
const rsbuildConfig = toRsbuildConfig({
output: {
inlineScripts: false,
},
})
expect(rsbuildConfig.output?.inlineScripts).toMatchInlineSnapshot(
`false`,
)
})

test('transform output.legalComments', () => {
const rsbuildConfig = toRsbuildConfig({
output: {
Expand Down