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

fix: Fixed issue with CJS being imported as ESM #2168

Merged
merged 8 commits into from
Apr 26, 2024

Conversation

jsumners-nr
Copy link
Contributor

This PR resolves #2155. This PR supercedes #2158.

@jsumners-nr jsumners-nr marked this pull request as ready for review April 26, 2024 16:52
Copy link
Member

@bizob2828 bizob2828 left a comment

Choose a reason for hiding this comment

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

overall makes sense and looks good. a few comments

package.json Outdated Show resolved Hide resolved
* SPDX-License-Identifier: Apache-2.0
*/

'use strict'
Copy link
Member

Choose a reason for hiding this comment

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

i'd put this in lib/util

test/unit/is-absolute-path.test.js Show resolved Hide resolved
t.context.agent = agent

const { default: foo } = await import('./foo.cjs?v=' + crypto.randomBytes(16).toString('hex'))
t.context.mod = foo
Copy link
Member

Choose a reason for hiding this comment

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

should you just import this and then access all 3 different exports and verify it works as expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think I understand the question. I have to import it after the "agent" is setup because otherwise the registerHooks will not pick up the module.

helper.instrumentMockedAgent = (conf, setState = true, shimmer = require('../../lib/shimmer')) => {
shimmer.debug = true
const agent = helper.loadMockedAgent(conf, setState)
shimmer.bootstrapInstrumentation(agent)
shimmer.registerHooks(agent)
helper.maybeLoadSecurityAgent(agent)
return agent
}

Copy link
Member

Choose a reason for hiding this comment

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

oh so i meant importing the file to get at default, foo and just the raw module.exports. Looking at this right now you're just getting default correct?

test/integration/issue-2155/test.tap.mjs Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Newrelic + Fastify: Function.prototype.apply was called on #<Object>, which is an object and not a function
2 participants