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

Use type=module for application.js #6846

Merged
merged 3 commits into from
Aug 15, 2024
Merged

Use type=module for application.js #6846

merged 3 commits into from
Aug 15, 2024

Conversation

AshGDS
Copy link
Contributor

@AshGDS AshGDS commented Jul 19, 2024

What / Why

@AshGDS AshGDS self-assigned this Jul 19, 2024
@govuk-ci govuk-ci temporarily deployed to smart-answers-pr-6846 July 19, 2024 10:17 Inactive
@AshGDS AshGDS changed the title Use type=module for application.js [DO NOT MERGE] Use type=module for application.js Jul 23, 2024
@AshGDS AshGDS added the DO NOT MERGE Needs further approval before release label Jul 23, 2024
@AshGDS AshGDS marked this pull request as ready for review July 24, 2024 09:31
@AshGDS AshGDS requested a review from MartinJJones July 24, 2024 09:34
Copy link
Contributor

@MartinJJones MartinJJones left a comment

Choose a reason for hiding this comment

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

Looks good to me, the JS error appears to be caused by the closest polyfill imported from the publishing components gem and using type="module".

If this PR could also include the upgrade to the gem that removes support for older browsers and polyfills when released, this will resolve the issue.

Further info on the error:

Uncaught TypeError:
Cannot read properties of undefined (reading 'Element')
    at application.js:3:6

The reason for this appears to be that a top level this is undefined when used in a module, before this change it was the window object - https://exploringjs.com/es6/ch_modules.html#sec_modules-vs-scripts

@govuk-ci govuk-ci temporarily deployed to smart-answers-pr-6846 August 15, 2024 15:51 Inactive
@AshGDS AshGDS changed the title [DO NOT MERGE] Use type=module for application.js Use type=module for application.js Aug 15, 2024
@AshGDS AshGDS removed the DO NOT MERGE Needs further approval before release label Aug 15, 2024
@AshGDS AshGDS merged commit 037120d into main Aug 15, 2024
13 checks passed
@AshGDS AshGDS deleted the type-module-changes branch August 15, 2024 16:08
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.

4 participants