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

allowJs may cause circular dependency error/warning in ./dist-raw #1488

Closed
cspotcode opened this issue Oct 7, 2021 · 0 comments · Fixed by #1489
Closed

allowJs may cause circular dependency error/warning in ./dist-raw #1488

cspotcode opened this issue Oct 7, 2021 · 0 comments · Fixed by #1489
Milestone

Comments

@cspotcode
Copy link
Collaborator

Accessing non-existent property 'getOptionValue' of module exports inside circular dependency

This happens when using allowJs. We have some code running inside our require.extensions['.js'] compile hook that is trying to require() an internal helper file, dist-raw/node-options. This file is '.js', so it triggers the same require hook with allowJs, which causes a circular dependency. The fix is to eagerly require this stuff so we're not require()ing dynamically within our CJS hooks.

const { getOptionValue } = require('./node-options');

Appears assertScriptCanLoadAsCJSImpl needs to check package.json type field, which triggers the circular dependency.

(node:3327) Warning: Accessing non-existent property 'getOptionValue' of module exports inside circular dependency
    at emitCircularRequireWarning (node:internal/modules/cjs/loader:707:11)
    at Object.get (node:internal/modules/cjs/loader:721:5)
    at Object.read (/d/Personal-dev/@TypeStrong/ts-node/repro-1477/dist-raw/node-package-json-reader.js:29:11)
    at readPackage (/d/Personal-dev/@TypeStrong/ts-node/repro-1477/dist-raw/node-cjs-loader-utils.js:63:36)
    at readPackageScope (/d/Personal-dev/@TypeStrong/ts-node/repro-1477/dist-raw/node-cjs-loader-utils.js:44:19)
    at assertScriptCanLoadAsCJSImpl (/d/Personal-dev/@TypeStrong/ts-node/repro-1477/dist-raw/node-cjs-loader-utils.js:20:15)
    at Object.require.extensions.<computed> [as .js] (/d/Personal-dev/@TypeStrong/ts-node/repro-1477/src/index.ts:1302:5)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
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 a pull request may close this issue.

1 participant