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

Error on last release #20

Closed
borjadotai opened this issue Apr 9, 2018 · 5 comments
Closed

Error on last release #20

borjadotai opened this issue Apr 9, 2018 · 5 comments

Comments

@borjadotai
Copy link

Hey there!

Awesome work with this troch, just wanted to let you know that on the last release you've published, it breaks saying that Path is not a constructor.

Just by using const p = new Path('/api/names/:name/:number');

But somehow it says that is not a constructor.
As soon as I downgrade to another version of the package, the same code works just fine!

@troch
Copy link
Owner

troch commented Apr 9, 2018

Two questions:

  • By new version, do you mean 4.0.x? (i.e not the latest patch)
  • How do you import Path? ES imports or commonJS require?

@borjadotai
Copy link
Author

borjadotai commented Apr 9, 2018

  1. I'm not entirely sure, I just installed the one that came from running npm i --save path-parser which apparently is path-parser@4.0.4

  2. const Path = require('path-parser');

@troch
Copy link
Owner

troch commented Apr 9, 2018

Ah, that's weird: 59f43c5 🤔

I added a named export, and it caused rollup to compile the default export from module.exports = Path to module.exports.default = Path. Not sure if it is an issue with Rollup or TypeScript

@troch
Copy link
Owner

troch commented Apr 9, 2018

So the issue was with previous versions and a configuration option missed in tsConfig.json.

Correct way to import with require is:

const { Path } = require('path-parser')
// or
const Path = require('path-parser').default

@borjadotai
Copy link
Author

Great! Thanks for clarifying and updating the README 😉
Again, amazing work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants