Skip to content

update import statements for downstream esm compatibility #169

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

modern-dev-dude
Copy link

Issue #, if available:
When compiling consuming packages to ESM using tsc, the following errors appeared at runtime

Error: Dynamic require of "console" is not supported
Error: Dynamic require of "url" is not supported

package.json in consuming

{
  "type": "module"
}

tsconfig in consuming package:

"jsx": "react",
"rootDir": "./src",
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true,
"target": "es2022",
"esModuleInterop": true,
"allowJs": true,
"resolveJsonModule": true,
"moduleDetection": "force",
"isolatedModules": true,
"strict": true,
"noUncheckedIndexedAccess": true,
"module": "NodeNext",
"outDir": "dist",
"sourceMap": true,
"verbatimModuleSyntax": true,
"declaration": true,
"lib": ["es2022"]

Description of changes:

  • removes the import url = require('url') and adds import url from 'url'
  • removes the import of Console and changes the constructor to new console.Console leveraging the global variable at runtime

Thanks for taking time to review! :)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

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.

1 participant