Unverified Commit 5b17dfeb authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: allow resolving TS files in tailwind config (#90046)

A regression from https://github.com/vercel/next.js/issues/86576

Closes https://github.com/vercel/next.js/issues/87898
Closes PACK-6421
parent d52d9336
......@@ -177,6 +177,7 @@ impl ServerNftJsonAsset {
let asset_context = Vc::upcast(externals_tracing_module_context(
get_tracing_compile_time_info(),
false,
));
let project_path = self.project.project_path().owned().await?;
......
......@@ -19,6 +19,9 @@ describe('tailwind-css', () => {
.elementByCss('#test-link')
.getComputedCss('color')
expect(cssBlue).toBe('rgb(37, 99, 235)')
expect(next.cliOutput).not.toContain('Module not found')
expect(next.cliOutput).not.toContain("Can't resolve")
} finally {
await browser.close()
}
......
// importing externals should work fine
require('fs')
require('path')
// importing typescript files should work fine
require('./my-plugin')
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ['./app/**/*.{js,ts,jsx,tsx}'],
......
......@@ -27,6 +27,9 @@ pub enum TsConfigHandling {
#[turbo_tasks::value(shared)]
#[derive(Default, Clone)]
pub struct ResolveOptionsContext {
/// 1. override options.node_externals and
/// 2. append environment.resolve_conditions
/// 3. override options.extensions
pub emulate_environment: Option<ResolvedVc<Environment>>,
pub enable_types: bool,
pub enable_typescript: bool,
......
......@@ -138,5 +138,6 @@ pub async fn config_tracing_module_context(
)
.cell()
.await?,
true,
)))
}
......@@ -893,9 +893,15 @@ async fn process_default_internal(
#[turbo_tasks::function]
pub async fn externals_tracing_module_context(
compile_time_info: Vc<CompileTimeInfo>,
resolve_typescript: bool,
) -> Result<Vc<ModuleAssetContext>> {
let mut extensions = vec![rcstr!(".js"), rcstr!(".node"), rcstr!(".json")];
if resolve_typescript {
extensions.insert(0, rcstr!(".ts"));
}
let resolve_options = ResolveOptionsContext {
enable_node_native_modules: true,
custom_extensions: Some(extensions),
emulate_environment: Some(compile_time_info.await?.environment),
loose_errors: true,
collect_affecting_sources: true,
......@@ -1078,6 +1084,7 @@ impl AssetContext for ModuleAssetContext {
let origin = PlainResolveOrigin::new(
Vc::upcast(externals_tracing_module_context(
*options.compile_time_info,
false,
)),
// If target is specified, a symlink will be created to
// make the folder
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment