Skip to content
Closed
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
3 changes: 2 additions & 1 deletion packages/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@
"@shopify/theme-language-server-node": "2.21.2",
"chokidar": "3.6.0",
"h3": "1.15.11",
"yaml": "2.9.0"
"js-yaml": "4.1.1"
},
"devDependencies": {
"@shopify/theme-hot-reload": "^0.0.22",
"@types/js-yaml": "^4.0.9",
"@vitest/coverage-istanbul": "^3.1.4",
"node-stream-zip": "^1.15.0"
},
Expand Down
10 changes: 5 additions & 5 deletions packages/theme/src/cli/services/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
type Theme,
path as pathUtils,
} from '@shopify/theme-check-node'
import YAML from 'yaml'
import {dump as yamlDump} from 'js-yaml'

type OffenseMap = Record<string, Offense[]>
Comment on lines +16 to 18

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for flagging — I checked this carefully and it's safe as written.

js-yaml@4.1.1 (the version we pin to) is dual-package, not CJS-only. Its exports map resolves the import condition to a real ESM build:

"exports": { ".": { "import": "./dist/js-yaml.mjs", "require": "./index.js" } }

and dist/js-yaml.mjs ends with a genuine named export — export { ..., dump, load, loadAll, ... }. So Node's ESM loader selects the .mjs directly and dump is a true named export; there's no CJS named-export heuristic in play and no "Named export 'dump' not found" risk.

Verified at runtime — a pure-ESM import { dump as yamlDump } from 'js-yaml' from this package resolves 4.1.1 with typeof dump === 'function' and produces correct YAML.

Worth noting the concern would have applied to 4.1.0, which is pure CJS — 4.1.1 is the release that added the ESM build, and we pin to 4.1.1 exactly.


Expand Down Expand Up @@ -265,9 +265,9 @@ export async function initConfig(root: string) {
// The initialized config will extend the recommended settings and
// will simply show the commented checks for the user to customize.
const {settings} = await loadConfig(undefined, root)
const checksYml = commentString(YAML.stringify(settings))
const checksYml = commentString(yamlDump(settings))

const initConfigYml = YAML.stringify({extends: 'theme-check:recommended', ignore: ['node_modules/**']})
const initConfigYml = yamlDump({extends: 'theme-check:recommended', ignore: ['node_modules/**']})

await writeFile(filePath, `${initConfigYml}${checksYml}`)

Expand Down Expand Up @@ -301,7 +301,7 @@ export async function outputActiveConfig(themeRoot: string, configPath?: string,
...settings,
}
const output = environment ? {[environment]: config} : config
outputResult(YAML.stringify(output))
outputResult(yamlDump(output))
}

export async function outputActiveChecks(root: string, configPath?: string, environment?: string) {
Expand Down Expand Up @@ -341,7 +341,7 @@ export async function outputActiveChecks(root: string, configPath?: string, envi
}, {})

const output = environment ? {[environment]: checksList} : checksList
outputResult(YAML.stringify(output))
outputResult(yamlDump(output))
}

interface ExtendedWriteStream extends NodeJS.WriteStream {
Expand Down
14 changes: 11 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading