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

Component JS files are only available in ESM syntax #937

Open
jakeb-nhs opened this issue Apr 12, 2024 · 0 comments
Open

Component JS files are only available in ESM syntax #937

jakeb-nhs opened this issue Apr 12, 2024 · 0 comments

Comments

@jakeb-nhs
Copy link

What is the issue?

The component JS files available within the packages folder of the nhsuk-frontend distribution are only available in ESM syntax. This causes an issue when the consuming application is not using the ESM module type (but for instance uses CJS instead).

In order to support CJS applications there should be CJS versions of these JS files available, either instead of ESM, or in addition to ESM (by using different entrypoints via package.json).

What steps are required to reproduce the issue?

Import one of the JS files in an application which requires CJS for it's dependencies. E.g.

import HeaderJs from 'nhsuk-frontend/packages/components/header/header';

The CJS loader will complain about unexpected export tokens - this is because it cannot handle ESM syntax.

Current workaround

The JS files need to be copied into the consuming application (rather than referencing the nhsuk-frontend dependency) so that they can be transpiled to CJS syntax when needed.

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