Hi @shockey
Let me first summarize our earlier conversation about the issues i ran into bundling swagger-ui into a webpack-2 project.
npm install swagger-uiimport Swagger from 'swagger-ui'ERROR in ./~/yaml-js/lib/yaml.js
Module not found: Error: Can't resolve 'fs' in '/project-path/node_modules/yaml-js/lib'
node: {
fs: 'empty'
},
-
Uncaught Error: Cannot find module "."./~/yaml-js/lib/yaml.js
require.extensions is not supported by webpack. Use a loader instead.
-
webpack.ProvidePlugin to stub require.extensions to null:new webpack.ProvidePlugin({
'require.extensions': null
})
-
so what ended up working for me is simply using the swagger-ui-dist package.
import SwaggerUI, { presets } from 'swagger-ui-dist/swagger-ui-bundle';
I used swagger-ui-bundle, the full dist file with all dependencies loaded, because in that case the yaml-js dependency was already resolved by swagger's webpack 1 build.
I'd love to help get a true webpack 2 build working if possible, given the limitations of yaml-js, but for now I'm satisfied and this seems to be working fine.
Hey again, @olslash!
Is your webpack2 project available anywhere? I'm going to dig into this soon, but it would save me some time to not need to build out a test project.
sorry, it's not -- work project
best you could do i guess is start with a webpack2 boilerplate :)
@olslash, I think https://github.com/swagger-api/swagger-ui/pull/3281 solves your issue!
Also, that PR was just a formality - if you do a fresh npm install of your project you should pick up [email protected]. Let me know how it fares 馃槃
thanks! Will have a look as soon as i get a chance
@olslash, bump 馃槃 let me know if you get a chance to give this a try.
hey @shockey -- just tried, and it works great!
replaced:
import { SwaggerUIBundle } from 'swagger-ui-dist';
const { presets } = SwaggerUIBundle;
import 'swagger-ui-dist/swagger-ui.css';
with
import SwaggerUIBundle from 'swagger-ui';
const { presets } = SwaggerUIBundle;
import 'swagger-ui/dist/swagger-ui.css';
Awesome! Glad to hear it.
I'm going to close this since the problem is solved, feel free to open a ticket if you come across any other issues.
Most helpful comment
Awesome! Glad to hear it.
I'm going to close this since the problem is solved, feel free to open a ticket if you come across any other issues.