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

Babel plugin can't be used in a TS monorepo before building the code #1702

Open
1999 opened this issue Aug 1, 2024 · 1 comment
Open

Babel plugin can't be used in a TS monorepo before building the code #1702

1999 opened this issue Aug 1, 2024 · 1 comment

Comments

@1999
Copy link

1999 commented Aug 1, 2024

Describe the bug
Our monorepo contains TS files. Babel plugin expects the required/imported files to exist when it is being used. However, we don't run the "build" command, therefore we don't have transpiled JS files.

The actual error message in our case looks like this:

     /Users/<username>/atlassian/afm/<path>/notification-component.tsx: Cannot find module '@atlaskit/tokens' from '/Users/<username>/atlassian/afm/<project>/node_modules/@compiled/babel-plugin/dist/utils'

To Reproduce
Steps to reproduce the behavior:

  1. TS Monorepo without built JS files
  2. Unit tests using "babel-jest"
  3. @compiled/babel-plugin in babel.config.json

Expected behavior
No error

@1999
Copy link
Author

1999 commented Aug 1, 2024

Looks like there's a solution: using a "resolver" option for the plugin which hasn't been documented yet. I will try to build a sample resolver and see if it works for us.

"plugins": [
		["@compiled/babel-plugin", {
			"parserBabelPlugins": ["typescript", "jsx"],
			"extensions": [".js", ".jsx", ".ts", ".tsx"],
			"resolver": "./compiled-resolver.js"
		}]
	]

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

No branches or pull requests

1 participant