preactjs / wmr

👩‍🚀 The tiny all-in-one development tool for modern web apps.
https://wmr.dev/
MIT License
4.92k stars 109 forks source link

"Invalid Specifier" due to "+" character (build metadata) in semver #929

Open micschro opened 2 years ago

micschro commented 2 years ago

Describe the bug The semver spec allows adding build metadata information to the semver string. The metadata information is added by appending it after a "+" character: `mylib-1.0.0+metainfo. When such a semver occurs in the project package.json, the wmr build will throw with an "Invalid specifier" message.

To Reproduce Add a module that uses a semver with metadata to the project:

"dependencies": {
    "mylib": "../mylib/mylib-1.0.1+foo.tgz"
},

And use it somehwere in the app:

import mylib from 'mylib'

Expected behavior Semver with build metadata should be supported

Bug occurs with:

Desktop (please complete the following information):

Additional context Apparently, wmr uses a regex to match the semver parts. This regex just seems to lack the "+" character. So, just adding it like this should fix this problem: ^((?:@[\w.-]{1,200}\/)?[\w.-]{1,200})(?:@([a-z0-9^.~>=<+-]{1,50}))?(?:\/(.*))?$