Skip to content

Support 'exports' field in package.json of published modules. #1389

@pilaoda

Description

@pilaoda

There are two problems about this field.

First:

const resolver = resolve.ResolverFactory.createResolver({
extensions: [".lua"],
enforceExtension: true, // Resolved file must be a lua file
fileSystem: { ...new resolve.CachedInputFileSystem(fs) },
useSyncFileSystemCalls: true,
symlinks: false, // Do not resolve symlinks to their original paths (that breaks node_modules detection)
});

The resolver should add conditions to support export conditions in a published module's package.json like:

{
    "exports": {
        "./client": {
            "require": "./dist/client/index.lua",
            "types": "./src/index.ts"
        }
    },
}

I guess we should add ["node", "require"], and maybe "tstl" ?
Related doc:

Second:

resolved = resolve.sync(query, { basedir, extensions: [".js", ".ts", ".tsx"] });

resolvePlugin use node-resolve rather than enhanced-resolve, which not support this "exports" field.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions