swagger-api / swagger-api/swagger-codegen
[Javascript] Webpack 3.0 unexpected token ===
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Just helping any internet searchers coming around until Webpack fixes this.
If you are
- using Webpack 3
- with parser.amd = false as per the Readme
You will run into this issue https://github.com/webpack/webpack/issues/5198.
The problematic line for me is in ApiClient.prototype.isFileParam.
if (typeof window === 'undefined' &&
typeof require === 'function' && // <------ here
require('fs') &&
param instanceof require('fs').ReadStream) {
return true;
}
Swagger-codegen version
Tried with 2.2.0 and 2.2.2.
Swagger declaration file content or url
Command line used for generation
Steps to reproduce
require()Swagger generated files from Webpack 3.
Related issues
Suggest a Fix
Go back to the old hack using imports-loader?define=false which still works until the bug is fixed.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The report points to the generated JavaScript ApiClient.prototype.isFileParam code and the README setting parser.amd=false. Start by locating that generated code in the JavaScript templates, then reproduce requiring generated files with Webpack 3. Done when the generated client no longer triggers the reported unexpected-token failure under that setup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, webpack
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100