Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transpile import.meta.url in config files #13322

Merged
merged 3 commits into from
Mar 22, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -75,7 +75,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