Skip to content

Commit

Permalink
Transpile import.meta.url in config files (#13322)
Browse files Browse the repository at this point in the history
* Use Babel to transpile configs when import.meta is present

* Update minimum jiti version

* Update changelog
  • Loading branch information
thecrypticace committed Mar 22, 2024
1 parent 44b3b42 commit b10b431
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add `mix-blend-plus-darker` utility ([#12923](https://github.com/tailwindlabs/tailwindcss/pull/12923))
- Ensure dashes are allowed in variant modifiers ([#13303](https://github.com/tailwindlabs/tailwindcss/pull/13303))
- Fix crash showing completions in Intellisense when using a custom separator ([#13306](https://github.com/tailwindlabs/tailwindcss/pull/13306))
- Transpile `import.meta.url` in config files ([#13322](https://github.com/tailwindlabs/tailwindcss/pull/13322))

## [3.4.1] - 2024-01-05

Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"fast-glob": "^3.3.0",
"glob-parent": "^6.0.2",
"is-glob": "^4.0.3",
"jiti": "^1.19.1",
"jiti": "^1.21.0",
"lilconfig": "^2.1.0",
"micromatch": "^4.0.5",
"normalize-path": "^3.0.0",
Expand Down
5 changes: 5 additions & 0 deletions src/lib/load-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ function lazyJiti() {
(jiti = jitiFactory(__filename, {
interopDefault: true,
transform: (opts) => {
// Sucrase can't transform import.meta so we have to use Babel
if (opts.source.includes('import.meta')) {
return require('jiti/dist/babel.js')(opts)
}

return transform(opts.source, {
transforms: ['typescript', 'imports'],
})
Expand Down
5 changes: 5 additions & 0 deletions standalone-cli/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ useCustomJiti(() =>
interopDefault: true,
nativeModules: Object.keys(localModules),
transform: (opts) => {
// Sucrase can't transform import.meta so we have to use Babel
if (opts.source.includes('import.meta')) {
return require('jiti/dist/babel.js')(opts)
}

return transform(opts.source, {
transforms: ['typescript', 'imports'],
})
Expand Down

0 comments on commit b10b431

Please sign in to comment.