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

unable to build #92

Open
nitinmcsam opened this issue Aug 9, 2022 · 13 comments
Open

unable to build #92

nitinmcsam opened this issue Aug 9, 2022 · 13 comments

Comments

@nitinmcsam
Copy link

No description provided.

@nitinmcsam
Copy link
Author

openapi-snippet@0.14.0 build
mkdir -p dist && browserify -g uglifyify ./index.js > ./dist/openapisnippet.min.js

SyntaxError: Unexpected token: operator (?) while parsing file: /home/mcsam/Desktop/test/openapi-snippet/openapi-to-har.js
at Z.get (/home/mcsam/Desktop/test/openapi-snippet/node_modules/terser/dist/bundle.min.js:1:463)
at Readable.errorExit (/home/mcsam/Desktop/test/openapi-snippet/node_modules/browserify/bin/cmd.js:79:27)
at Readable.emit (node:events:527:28)
at Labeled. (/home/mcsam/Desktop/test/openapi-snippet/node_modules/read-only-stream/index.js:28:44)
at Labeled.emit (node:events:527:28)
at Labeled. (/home/mcsam/Desktop/test/openapi-snippet/node_modules/stream-splicer/index.js:130:18)
at Labeled.emit (node:events:527:28)
at Deps. (/home/mcsam/Desktop/test/openapi-snippet/node_modules/stream-splicer/index.js:130:18)
at Deps.emit (node:events:527:28)
at DuplexWrapper. (/home/mcsam/Desktop/test/openapi-snippet/node_modules/module-deps/index.js:414:22)

@nitinmcsam
Copy link
Author

after build command

@lebiscuithd
Copy link

Same issue here

@jdeniau
Copy link

jdeniau commented Oct 4, 2022

Same issue with webpack that wants a specific loader.

ERROR in ./node_modules/openapi-snippet/openapi-to-har.js 230:17
Module parse failed: Unexpected token (230:17)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| 
|   const objects = [];
>   style = style ?? getDefaultStyleForLocation(location);
|   explode = explode ?? getDefaultExplodeForStyle(style);
| 
 @ ./node_modules/openapi-snippet/index.js 11:21-51
 @ ./docs/App.js
 @ ./docs/index.js

Version ^0.13 does work, but 0.14.0 does not work. Maybe @michaelgwelch might know why ?

@michaelgwelch
Copy link
Contributor

I can take a look

@michaelgwelch
Copy link
Contributor

FYI, we use version 0.14.0 which has been working for us and which I believe was the first released version to include my changes.

@michaelgwelch
Copy link
Contributor

michaelgwelch commented Oct 4, 2022

Is this a minimum version of node issue? Perhaps I (and @ErikWittern ) used a newer version of node. Is the ?? operator not supported in your version of node?

If that's the issue, it's easily fixed by using || instead of ?? (I think).

@michaelgwelch
Copy link
Contributor

michaelgwelch commented Oct 4, 2022

Looks like ?? was added in node 14.5 per https://node.green/#ES2020-features--nullish-coalescing-operator-----

So perhaps this library needs to specify a minimum version of node, or rewrite that little bit to not use ?? operator.

Unfortunately, I think Erik is rather busy. I've submitted another issue and PR to fix it and haven't heard anything back. So while I can create a fix and make a PR, it's unlikely to be merged for some time.

@jdeniau
Copy link

jdeniau commented Oct 4, 2022

Thanks for looking at it.

My node version is 14.18.0 for the record and the null coalesce opérator does work

image

@michaelgwelch
Copy link
Contributor

michaelgwelch commented Oct 4, 2022

Just wondering. Could you clone the repo, and npm install and npm run test? I'm going to test it locally using your version of node.

The only issue I find with v14.18.0 is that the replaceAll method on string isn't supported until v15.14 (https://node.green/#ES2021-features--String-prototype-replaceAll) but that's only used in the test file and isn't used in the library code itself.

@jdeniau
Copy link

jdeniau commented Oct 11, 2022

image

According to MDN replaceAll has been introduced in node 15.

But the only reference is in a test file.

The webpack issues seems weird though as a loader is something that is determined by the file extension.

@jsau-
Copy link

jsau- commented May 4, 2023

Looks like ?? was added in node 14.5 per https://node.green/#ES2020-features--nullish-coalescing-operator-----

So perhaps this library needs to specify a minimum version of node, or rewrite that little bit to not use ?? operator.

I did open a PR to replace the ?? operators with checks compatible with lower versions of Node last July I think (see #91).

If that's been superceded by anything you've done just let me know and I can close mine!

@zak905
Copy link

zak905 commented Nov 9, 2023

Hi @michaelgwelch, I am also encountring this issue. My node version is v14.17.1. I think that maybe providing a ready to use script for those who do not want or who cannot build the repo, can help. Many projects do it, including Swagger UI: https://github.com/swagger-api/swagger-ui/tree/master/dist

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

6 participants