Skip to content

Conversation

thecrypticace
Copy link
Contributor

@thecrypticace thecrypticace commented Sep 22, 2025

v2.6.0 of Jiti comes with a nice perf bump from lazy loading babel only when necessary.

edit: Had to patch it in a way that negates this. Will explore alternatives to bundling to see if we can get this functionality back in the future though.

Nice initialization perf improvement
@thecrypticace
Copy link
Contributor Author

Looks like I'm getting this:

Error: Cannot find module '../dist/babel.cjs'
Require stack:
- /Users/jordanpittman/Developer/tailwind-labs/projects/prettier-plugin-tailwindcss/dist/index.mjs
    at Module._resolveFilename (node:internal/modules/cjs/loader:1405:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1061:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1066:22)
    at Module._load (node:internal/modules/cjs/loader:1215:37)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
    at Module.require (node:internal/modules/cjs/loader:1491:12)
    at require (node:internal/modules/helpers:135:16)
    at Object.fse [as transform] (file:///Users/jordanpittman/Developer/tailwind-labs/projects/prettier-plugin-tailwindcss/dist/index.mjs:1251:5911)
    at file:///Users/jordanpittman/Developer/tailwind-labs/projects/prettier-plugin-tailwindcss/dist/index.mjs:1250:1220 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/jordanpittman/Developer/tailwind-labs/projects/prettier-plugin-tailwindcss/dist/index.mjs'
  ]
}

This may be be related to our use of esbuild? Not sure yet.

@thecrypticace
Copy link
Contributor Author

thecrypticace commented Sep 22, 2025

Ah it's because Jiti assumes that it's build of babel will be available in node_modules:

function lazyTransform(...args) {
  if (!_transform) {
    _transform = createRequire(import.meta.url)("../dist/babel.cjs");
  }
  return _transform(...args);
}

We'll have to figure out how to patch this so it's either inlined (negates the perf benefit tho) or stored beside the prettier files.

@thecrypticace thecrypticace marked this pull request as draft September 22, 2025 18:55
This would negate the perf improvement sadly. We need to chunk split this dep.
@thecrypticace thecrypticace marked this pull request as ready for review September 22, 2025 20:21
Copy link
Member

@RobinMalfait RobinMalfait left a comment

Choose a reason for hiding this comment

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

Bit sad about the patch though

@thecrypticace thecrypticace merged commit f9f28a3 into main Sep 23, 2025
1 check passed
@thecrypticace thecrypticace deleted the feat/bump-jiti branch September 23, 2025 14:44
@thecrypticace
Copy link
Contributor Author

Same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants