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

chore(deps): update to [email protected] #30204

Closed
wants to merge 2 commits into from

Conversation

raygdev
Copy link
Contributor

@raygdev raygdev commented Sep 8, 2024

Additional details

  • 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 you code to strictly use CommonJS or ESM.

Steps to test

git clean -xfd
yarn
yarn workspace @packages/rewriter test

How has the user experience changed?

No change

PR Tasks

@cypress-app-bot
Copy link
Collaborator

@raygdev raygdev closed this Sep 8, 2024
@MikeMcC399
Copy link
Contributor

@raygdev

I wonder if this is due to the old mocha version? The error is coming from a mocha command.

$ yarn workspace @packages/rewriter test
yarn workspace v1.22.22
yarn run v1.22.22
$ mocha --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json
/home/mike/github/cypress-io/cypress/node_modules/ts-node/dist/index.js:851
            return old(m, filename);
                   ^
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/mike/github/cypress-io/cypress/packages/rewriter/node_modules/parse5-html-rewriting-stream/dist/index.js from /home/mike/github/cypress-io/cypress/packages/rewriter/lib/html.ts not supported.
Instead change the require of index.js in /home/mike/github/cypress-io/cypress/packages/rewriter/lib/html.ts to a dynamic import() which is available in all CommonJS modules.
    at require.extensions.<computed> [as .js] (/home/mike/github/cypress-io/cypress/node_modules/ts-node/dist/index.js:851:20)
    at Object.<anonymous> (/home/mike/github/cypress-io/cypress/packages/rewriter/lib/html.ts:5:40)
    at m._compile (/home/mike/github/cypress-io/cypress/node_modules/ts-node/dist/index.js:857:29)
    at require.extensions.<computed> [as .ts] (/home/mike/github/cypress-io/cypress/node_modules/ts-node/dist/index.js:859:16)
    at Object.<anonymous> (/home/mike/github/cypress-io/cypress/packages/rewriter/test/unit/html-spec.ts:5:16)
    at m._compile (/home/mike/github/cypress-io/cypress/node_modules/ts-node/dist/index.js:857:29)
    at require.extensions.<computed> [as .ts] (/home/mike/github/cypress-io/cypress/node_modules/ts-node/dist/index.js:859:16)
    at /home/mike/github/cypress-io/cypress/node_modules/mocha/lib/mocha.js:231:27
    at Array.forEach (<anonymous>)
    at Mocha.loadFiles (/home/mike/github/cypress-io/cypress/node_modules/mocha/lib/mocha.js:228:14)
    at Mocha.run (/home/mike/github/cypress-io/cypress/node_modules/mocha/lib/mocha.js:514:10)
    at Object.<anonymous> (/home/mike/github/cypress-io/cypress/node_modules/mocha/bin/_mocha:480:18) {
  code: 'ERR_REQUIRE_ESM'
}

"mocha": "3.5.3",

@raygdev
Copy link
Contributor Author

raygdev commented Sep 9, 2024

@MikeMcC399 I had considered that and tried to execute the file with ts-node separately trying to log to the terminal and isolate the error from mocha since running tests executed the command. It appeared to spit out the same error. I used the command yarn workspace @packages/rewriter ts-node lib/html.ts. If you run that command, it will print a similar error, but only from ts-node.

I will try to be more detailed next time. I thought I had actually put that in the messge there, but it looks like I completely forgot.

The only other, and last, thing I can think of is to open an issue with parse5 and ask for support for commonjs. It looks like they removed support for it when they released v7.0.0. I'm not sure if that will fix the issue, but it's the only thing that makes sense to me, that would, with my current understanding.

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.

Update to parse5-html-rewriting-stream 7.0.0
3 participants