GithubHelp home page GithubHelp logo

Comments (14)

dschnare avatar dschnare commented on June 19, 2024 1

That test scenario is perfect. That's what we have currently in our project. Some folders work, while others didn't so I had to specifically add an export for that folder.

from esmock.

iambumblehead avatar iambumblehead commented on June 19, 2024 1

@dschnare the PR was just updated so that the tests will pass in windows. Feel free to recommend any changes

from esmock.

iambumblehead avatar iambumblehead commented on June 19, 2024 1

if the overall approach is okay (as it seems to be) its good for me if the PR is accepted. Later on, when needed, the place that expands the asterisks on the right side could be improved for supporting more situations.

from esmock.

dschnare avatar dschnare commented on June 19, 2024

Reference: https://nodejs.org/docs/latest-v18.x/api/packages.html#subpath-patterns

from esmock.

dschnare avatar dschnare commented on June 19, 2024

Interestingly, this error only occurs for me for some subpaths and not others from a package. To workaround I had to use the pattern to catch most subpaths then have an explicit export for subpaths that cause the error.

{
  "exports": {
    "./*": {
     "default": "./src/*/index.js",
     "types": "./types/*/index.d.ts"
    },
    "./my-path": {
      "default": "./src/my-path/index.js",
      "types": "./src/my-path/index.d.ts"
    }
  }
}

from esmock.

iambumblehead avatar iambumblehead commented on June 19, 2024

@dschnare subpaths are supported and if one is not resolved correctly that's a bug. esmock uses resolvewithplus to resolve module ids, so that's where the solution should happen.

Node's dsl esm pattern language is tricky to parse. For resolvewithplus, official node examples were copied to unit-tests used by resolvewithplus and when missing cases have been discovered they've been resolved in new versions of resolvewithplus

from esmock.

iambumblehead avatar iambumblehead commented on June 19, 2024

@dschnare I have not seen wildcard export namespace names before, eg {"exports":{"./namepace*": { ... }}} that usage does not appear to be documented at the link you shared.

from esmock.

dschnare avatar dschnare commented on June 19, 2024

from esmock.

iambumblehead avatar iambumblehead commented on June 19, 2024

@dschnare thanks for reporting. Its always good to learn about these cases I didn't know about.

from esmock.

iambumblehead avatar iambumblehead commented on June 19, 2024

@dschnare is this what you think the exports, directory and file layout should look like for unit-testing this?

{
  "name": "asterisk-dir-name",
  "type": "module",
  "exports": {
    "./*": {
      "default": "./src/*/index.js",
      "types": "./types/*/index.d.ts"
    }
  }
}
.
├── package.json
├── src
│   └── mystuff
│       └── index.js
└── types
    └── mystuff
        └── index.d.ts

from esmock.

iambumblehead avatar iambumblehead commented on June 19, 2024

@dschnare I wonder specifically how the named-property asterisk and then its nested, matched value must correspond to each other and the specifier used to import such a module.

For example, should the outer "./*" return any directory or only a directory that corresponds with the imported moduleId?

Maybe we should first implement any basic solution and then refine that later as any edge-cases are reported to fail.

from esmock.

iambumblehead avatar iambumblehead commented on June 19, 2024

@dschnare iambumblehead/resolvewithplus#65

from esmock.

dschnare avatar dschnare commented on June 19, 2024

@iambumblehead It looks like from the documentation that the subpath pattern ./* would match any path like "mymodule/something", "mymodule/something/cool", etc. And technically * could be included multiple times in the export pattern. This I didn't know, but interesting.

All instances of * on the right hand side will then be replaced with this value, including if it contains any / separators.

from esmock.

dschnare avatar dschnare commented on June 19, 2024

@iambumblehead I understood that incorrectly. The * can appear multiple times on the right side. On the left side it appears it should only occur once.

from esmock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.