{"record":{"id":"13510cf82993d173","repo":"tailwindlabs/tailwindcss","slug":"no-loadmodule-function-provided-to-compile","errorCode":null,"errorMessage":"No `loadModule` function provided to `compile`","messagePattern":"No `loadModule` function provided to `compile`","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tailwindcss/src/index.ts","lineNumber":79,"sourceCode":"    base: string,\n    resourceHint: 'plugin' | 'config',\n  ) => Promise<{\n    path: string\n    base: string\n    module: Plugin | Config\n  }>\n  loadStylesheet?: (\n    id: string,\n    base: string,\n  ) => Promise<{\n    path: string\n    base: string\n    content: string\n  }>\n}\n\nfunction throwOnLoadModule(): never {\n  throw new Error('No `loadModule` function provided to `compile`')\n}\n\nfunction throwOnLoadStylesheet(): never {\n  throw new Error('No `loadStylesheet` function provided to `compile`')\n}\n\nfunction parseThemeOptions(params: string) {\n  let options = ThemeOptions.NONE\n  let prefix = null\n\n  for (let option of segment(params, ' ')) {\n    if (option === 'reference') {\n      options |= ThemeOptions.REFERENCE\n    } else if (option === 'inline') {\n      options |= ThemeOptions.INLINE\n    } else if (option === 'default') {\n      options |= ThemeOptions.DEFAULT\n    } else if (option === 'static') {","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/tailwindlabs/tailwindcss/blob/16e94cbf7f965c5ad697e90e940b5e178efad67c/packages/tailwindcss/src/index.ts#L61-L97","documentation":"Thrown by `throwOnLoadModule()`, the default value for the `loadModule` option of `compile()`. The compile pipeline calls `loadModule` only when it encounters `@plugin` or `@config` directives in CSS that require loading a JS module from disk. If the integrator did not supply a `loadModule` callback, the default throws to signal that JS module resolution is unavailable in the current environment (e.g. a browser/WASM build, or a custom compile call without a filesystem).","triggerScenarios":"Calling `compile(css, { ... })` without a `loadModule` option while the CSS contains `@plugin \"./my-plugin.js\"` or `@config \"./tailwind.config.js\"`. The standalone `compile` export defaults `loadModule` to `throwOnLoadModule`, so any `@plugin`/`@config` triggers it. Browsers and constrained runtimes cannot load filesystem modules, hence the guard.","commonSituations":"Using the Tailwind v4 compiler in a browser/WASM/edge environment where `@plugin` or `@config` is present but no FS loader exists; calling the low-level `compile` API directly (instead of the PostCSS plugin or CLI which wire up `loadModule`); keeping a `@config` directive after migrating to v4.","solutions":["Remove the `@plugin` / `@config` directive from the CSS if you do not need JS plugins in this environment.","Provide a `loadModule` callback to `compile` that resolves and imports the module (the PostCSS plugin and CLI already do this).","If you are in a browser/edge runtime, port the plugin's behavior to CSS/`@theme` instead of a JS module.","For v4, prefer the CSS-first config (`@theme`, `@plugin` only when you control loading) over `@config`."],"exampleFix":"// before\nimport { compile } from 'tailwindcss'\n// css contains: @plugin \"./my-plugin.js\";\nlet result = await compile(css)\n// after\nimport { compile } from 'tailwindcss'\nlet result = await compile(css, {\n  loadModule: async (id, base) => {\n    let path = await resolve(id, base)\n    return { path, base, module: await import(path) }\n  },\n})","handlingStrategy":"validation","validationCode":"function needsLoadModule(css: string): boolean {\n  return /@plugin\\s+|@config\\s+/.test(css);\n}\n// Before calling compile:\nif (needsLoadModule(css) && typeof options.loadModule !== 'function') {\n  throw new Error('CSS uses @plugin/@config but no loadModule was provided');\n}","typeGuard":"function hasLoadModule(opts: CompileOptions): opts is CompileOptions & { loadModule: NonNullable<CompileOptions['loadModule']> } {\n  return typeof opts.loadModule === 'function';\n}","tryCatchPattern":"try {\n  await compile(css, opts);\n} catch (e) {\n  if (e instanceof Error && e.message === 'No `loadModule` function provided to `compile`') {\n    // either remove @plugin/@config or supply a loadModule\n  } else throw e;\n}","preventionTips":["Avoid @plugin/@config in browser/edge builds of the compiler.","When using the low-level compile API, always pass loadModule and loadStylesheet.","Migrate v3 @config usage to v4 CSS-first @theme where possible.","Use the official PostCSS plugin or CLI, which wire up module loading for you."],"tags":["tailwind-v4","compile","loadmodule","plugin","config","runtime"],"backgroundTag":null,"analyzedSha":"16e94cbf7f965c5ad697e90e940b5e178efad67c","analyzedAt":"2026-08-12T06:02:42.469Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}