enhanced-resolve icon indicating copy to clipboard operation
enhanced-resolve copied to clipboard

Exports subpath wildcard patterns issue.

Open scott-lc opened this issue 2 years ago • 1 comments

Referring to the Node subpath patterns documentation, notice how a pattern can specify a file extension (in this example .js) on both sides of the pattern mapping:

{
  "exports": {
    "./features/*.js": "./src/features/*.js"
  }
}

According to the Node docs,

Including the "*.js" on both sides of the mapping restricts the exposed package exports to only JS files.

However, this does not work in enhanced-resolved. The wildcard pattern without a file extension works fine, for example:

{
  "exports": {
    "./features/*": "./src/features/*"
  }
}

But adding a wildcard file extension does not work. To test this, simply add the following test case to test/exportFields.js:

// ./test/exportFields.js
const testCases = [
  //...
  {
    name: "This will fail!",
    expect: ["./src/features/file.js"],
    suite: [
	{
	  "./features/*.js": "./src/features/*.js"
	},
	"./features/file.js",
	[]
    ]
  }

scott-lc avatar Jul 25 '22 13:07 scott-lc

Sounds like a bug, do you want send a fix?

alexander-akait avatar Jul 25 '22 13:07 alexander-akait

Fixed by https://github.com/webpack/enhanced-resolve/pull/353

alexander-akait avatar Apr 19 '23 15:04 alexander-akait