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

Update to parse5-html-rewriting-stream 7.0.0 #30146

Open
MikeMcC399 opened this issue Aug 30, 2024 · 1 comment
Open

Update to parse5-html-rewriting-stream 7.0.0 #30146

MikeMcC399 opened this issue Aug 30, 2024 · 1 comment
Labels
process: dependencies Related to internal dependencies type: chore Work is required w/ no deliverable to end user

Comments

@MikeMcC399
Copy link
Contributor

What would you like?

  1. Update the npm module parse5-html-rewriting-stream to [email protected].
  2. Remove the use of the deprecated npm module @types/parse5-html-rewriting-stream.

Why is this needed?

The npm module @types/parse5-html-rewriting-stream is deprecated. The release information for [email protected] shows that types were added in this feature release in November 2022. The Breaking: TypeScript section includes the text:

To migrate, please remove @types/parse5* as we now ship our own types.

Other

Item Value
Deprecated npm module @types/parse5-html-rewriting-stream
npm registry message This is a stub types definition. parse5-html-rewriting-stream provides its own type definitions, so you do not need this installed.
Other message
GitHub repo https://github.com/inikulin/parse5
Repo status Active
Replacement npm module https://www.npmjs.com/package/parse5-html-rewriting-stream
Replacement repo https://github.com/inikulin/parse5/tree/master/packages/parse5-html-rewriting-stream
Replacement documentation https://parse5.js.org/modules/parse5_html_rewriting_stream.html
Migration docs https://github.com/inikulin/parse5/releases/tag/v7.0.0

Where used:

Directory Version
packages/rewriter "@types/parse5-html-rewriting-stream": "5.1.1"
"parse5-html-rewriting-stream": "5.1.1"
@jennifer-shehane jennifer-shehane added process: dependencies Related to internal dependencies type: chore Work is required w/ no deliverable to end user labels Aug 30, 2024
@raygdev
Copy link
Contributor

raygdev commented Sep 8, 2024

  • An error occurs after updating to v7.0.0 when running tests for this package
/Users/raymo/projects/cypress/node_modules/ts-node/dist/index.js:851
            return old(m, filename);
                   ^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/raymo/projects/cypress/packages/rewriter/node_modules/parse5-html-rewriting-stream/dist/index.js from /Users/raymo/projects/cypress/packages/rewriter/lib/html.ts not supported.
Instead change the require of index.js in /Users/raymo/projects/cypress/packages/rewriter/lib/html.ts to a dynamic import() which is available in all CommonJS modules.
    at require.extensions.<computed> [as .js] (/Users/raymo/projects/cypress/node_modules/ts-node/dist/index.js:851:20)
    at Object.<anonymous> (/Users/raymo/projects/cypress/packages/rewriter/lib/html.ts:5:40)
    at m._compile (/Users/raymo/projects/cypress/node_modules/ts-node/dist/index.js:857:29)
    at require.extensions.<computed> [as .ts] (/Users/raymo/projects/cypress/node_modules/ts-node/dist/index.js:859:16)
    at Object.<anonymous> (/Users/raymo/projects/cypress/packages/rewriter/test/unit/html-spec.ts:5:16)
    at m._compile (/Users/raymo/projects/cypress/node_modules/ts-node/dist/index.js:857:29)
    at require.extensions.<computed> [as .ts] (/Users/raymo/projects/cypress/node_modules/ts-node/dist/index.js:859:16)
    at /Users/raymo/projects/cypress/node_modules/mocha/lib/mocha.js:231:27
    at Array.forEach (<anonymous>)
    at Mocha.loadFiles (/Users/raymo/projects/cypress/node_modules/mocha/lib/mocha.js:228:14)
    at Mocha.run (/Users/raymo/projects/cypress/node_modules/mocha/lib/mocha.js:514:10)
    at Object.<anonymous> (/Users/raymo/projects/cypress/node_modules/mocha/bin/_mocha:480:18) {
  code: 'ERR_REQUIRE_ESM'
  • it appears as though parse5 has moved strictly to ESM and does not provide CommonJS support
  • ESM imports were used in the files but ts-node seems to require them under the hood.
  • Attempted to modify the tsconfig.json in that package based on the recommended way through ts-node here, along with a host of other variations. Nothing seemed to work. The recommendation from ts-node is to either try those configurations, downgrade the package to a version that uses CommonJS, or convert your code to strictly use CommonJS or ESM.

I just don't have a good idea of how to get this to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
process: dependencies Related to internal dependencies type: chore Work is required w/ no deliverable to end user
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants