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

Allow transpiling all js files inside yoastseo/src and allow import with asterisk * #21971

Merged
merged 6 commits into from
Jan 22, 2025

Conversation

FAMarfuaty
Copy link
Contributor

@FAMarfuaty FAMarfuaty commented Jan 17, 2025

Context

  • We don't want to miss any files when preparing the types.
  • We also want to explicitly allow imports with asterisks.

Summary

This PR can be summarized in the following changelog entry:

  • [yoastseo] Allows transpiling all JavaScript files inside src and vendor into TypeScript and allows importing modules with an asterisk *.

Relevant technical choices:

  • Adding the moduleResolution option in the config allows using import statement with an asterisk *. For example, import * as assessments from "./scoring/assessments";. Reference: moduleResolution
  • Changing "src/**.js" to "src/**/*.js" in include allows the transpiling of all Javascript files inside the src folder. Previously, not all JS files were transpiled. By using **/ now we should be able to match nested directory to any level. Reference: include
  • vendor is added to the include array inside tsconfig.json. This is because the Turkish external stemmer is stored in this folder. We also need to transpile the stemmer since we also use it inside src folder
  • The yarn clean script has also been changed to clean the generated types folder.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Set checkJs option inside packages/yoastseo/tsconfig.json to true to be able to build types (⚠️ don't commit this change)
  • Run yarn build:types inside yoastseo package
Allows transpiling all JavaScript files inside src and vendor into TypeScript
  • Confirm that you have types folder inside the root of yoastseo directory
  • Confirm that inside types folder, you see both src and vendor folders
  • Confirm that all js files inside src are transpiled
Allows importing modules with an asterisk *
  • Open this file packages/yoastseo/src/index.js . This file previously had errors in the import syntax with an asterisk
  • Confirm that now you don't see that error anymore for all imports that are using an asterisk
  • Go to packages/yoastseo/types/src/index.d.ts and confirm that the following modules are imported correctly:
    • AnalysisWebWorker, AnalysisWorkerWrapper, createWorker, assessments, assessors, bundledPlugins, config, helpers, markers, interpreters, languageProcessing, values
Removes types folder when yarn clean is executed
  • Remove the types folder inside yoastseo with rm -rf types
  • Inside yoastseo package, run yarn build
  • Confirm that you see build and types folder inside yoastseo
  • Run yarn clean
  • Confirm that both build and types folder inside yoastseo are removed

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

QA can test this PR by following these steps:

  • No user-facing changes, no need to test this as QA.

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes https://github.com/Yoast/lingo-other-tasks/issues/510

@FAMarfuaty FAMarfuaty changed the title Allow transpiling all js files inside yoastseo/src Allow transpiling all js files inside yoastseo/src and allow import with asterisk * Jan 17, 2025
@coveralls
Copy link

coveralls commented Jan 20, 2025

Pull Request Test Coverage Report for Build 75a29d53d44690cb47e44379c65b7a6ed8486c90

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall first build on fix-typescript-config at 57.493%

Totals Coverage Status
Change from base Build f7f95dc739fe7266db4edb615d5011d551edaa57: 57.5%
Covered Lines: 13426
Relevant Lines: 23009

💛 - Coveralls

@FAMarfuaty FAMarfuaty added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label Jan 20, 2025
@FAMarfuaty FAMarfuaty marked this pull request as ready for review January 20, 2025 10:28
Copy link
Contributor

@mhkuu mhkuu left a comment

Choose a reason for hiding this comment

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

Nice work! 🎉

packages/yoastseo/tsconfig.json Show resolved Hide resolved
@mhkuu mhkuu added this to the 24.5 milestone Jan 22, 2025
@mhkuu mhkuu merged commit df0bc85 into trunk Jan 22, 2025
17 checks passed
@mhkuu mhkuu deleted the fix-typescript-config branch January 22, 2025 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants