Skip to content

Behavior is different from require-in-the-middle #185

Open
@FredericEspiau

Description

@FredericEspiau

Hey and thanks for all the hard work,

Please note that this is related to this issue I've created in the dd-trace-js repository as I'm not sure who owns the responsibility for this issue: DataDog/dd-trace-js#5479

I think import-in-the-middle behaves differently from require-in-the-middle because of this line:

if (!baseDir.endsWith(specifiers.get(filename))) continue

I think it's an optimisation to avoid sending unnecessary files to the callback but it avoids some files that should be included.

For example, when given the filename file:///<redacted>/node_modules/.pnpm/@apollo+server@4.11.3_encoding@0.1.13_graphql@16.10.0/node_modules/@apollo/server/dist/esm/ApolloServer.js

baseDir will be <redacted>/node_modules/.pnpm/@apollo+server@4.11.3_encoding@0.1.13_graphql@16.10.0/node_modules/@apollo/server

specifiers.get(filename) will be ./ApolloServer.js

So when checking !baseDir.endsWith(specifiers.get(filename)) the computation will be false as you can see ./ApolloServer.js is not present in baseDir.

If I remove the line, it works.

For the same intended behavior, require-in-the-middle will provide all the files.

Thanks in advance and have a good day.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions