Skip to content

Commit 1a03f64

Browse files
authored
Merge pull request #593 from marp-team/new-headless-mode
Adopt new headless mode by default
2 parents 78e74b8 + ec1b443 commit 1a03f64

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
- Upgrade Marp Core to [v4.0.0](https://github.com/marp-team/marp-core/releases/v4.0.0) ([#591](https://github.com/marp-team/marp-cli/pull/591))
99
- The slide container of built-in themes became the block element and adopted safe centering
1010
- Relax HTML allowlist: Allowed a lot of HTML elements and attributes by default
11+
- Use [the new headless mode of Chrome](https://developer.chrome.com/docs/chromium/headless) while converting by default ([#593](https://github.com/marp-team/marp-cli/pull/593))
12+
- You can get back to the old headless mode by setting `PUPPETEER_HEADLESS_MODE=old` env.
1113

1214
### Added
1315

src/utils/puppeteer.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ let executablePath: string | undefined | false = false
1515
let wslTmp: string | undefined
1616

1717
export const enableHeadless = (): 'shell' | true =>
18-
process.env.PUPPETEER_HEADLESS_MODE?.toLowerCase() === 'new' ? true : 'shell'
18+
['old', 'legacy', 'shell'].includes(
19+
process.env.PUPPETEER_HEADLESS_MODE?.toLowerCase() ?? ''
20+
)
21+
? 'shell'
22+
: true
1923

2024
const isShebang = (path: string) => {
2125
let fd: number | null = null

test/utils/puppeteer.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,14 @@ describe('#generatePuppeteerLaunchArgs', () => {
201201
})
202202

203203
describe('with PUPPETEER_HEADLESS_MODE env', () => {
204-
it('uses legacy headless mode if PUPPETEER_HEADLESS_MODE was empty', async () => {
204+
it('uses headless mode if PUPPETEER_HEADLESS_MODE was empty', async () => {
205205
try {
206206
process.env.PUPPETEER_HEADLESS_MODE = ''
207207

208208
const { headless } =
209209
await puppeteerUtils().generatePuppeteerLaunchArgs()
210210

211-
expect(headless).toBe('shell')
211+
expect(headless).toBe(true)
212212
} finally {
213213
delete process.env.PUPPETEER_HEADLESS_MODE
214214
}
@@ -252,6 +252,19 @@ describe('#generatePuppeteerLaunchArgs', () => {
252252
delete process.env.PUPPETEER_HEADLESS_MODE
253253
}
254254
})
255+
256+
it('uses legacy headless mode if PUPPETEER_HEADLESS_MODE was "shell"', async () => {
257+
try {
258+
process.env.PUPPETEER_HEADLESS_MODE = 'shell'
259+
260+
const { headless } =
261+
await puppeteerUtils().generatePuppeteerLaunchArgs()
262+
263+
expect(headless).toBe('shell')
264+
} finally {
265+
delete process.env.PUPPETEER_HEADLESS_MODE
266+
}
267+
})
255268
})
256269

257270
describe('with CHROME_PATH env in macOS', () => {

0 commit comments

Comments
 (0)