mulesoft-labs / api-console-builder

A module to build a minified and concatenated file for the API console
Other
3 stars 7 forks source link

building `api-console` without packaged RAML #14

Closed mutsys closed 6 years ago

mutsys commented 6 years ago

I've been trying to use api-console-builder to create a package that I can load up the minimized assets in a browser and then programmatically setting the raml attribute of api-console. However, when I use the artifacts produced by the build, setting the raml attribute has no effect. I can inspect the state of the browser and see that scripts seem to load without any apparent errors, no messages show in the console, api-console has a raml attribute containing the expanded, enhanced RAML object and the <api-console> element has no children or content.

I run the builder as follows:

const builder = require('api-console-builder');
builder({
    tagName: "5.0.0-preview"
    embedded: true
})
.then(() => console.log('Build complete'))
.catch(console.log);

load it up in the browser:

<script src="/api-console/apic-import.js"></script>

and the at some point:

var apiConsole = document.querySelector("api-console");
apiConsole.raml = ramlObject;

once the document has loaded and web components are ready where ramObject is an expanded, enhanced RAML definition. This same approach works as expected using the unbundled api-console via link/import:

<link rel="import" href="/bower_components/api-console/api-console.html">

Should I expect this to work or must I defined values for api and/or apiType?

My guess right now is that there is something that I am failing to do upon setting up/loading the build artifacts in the browser. This is based on having tried to accomplish what I want three different ways (api-console-cli, api-console-builder and using webpack with polymer-webpack-loader) each of which produces the same result.

mutsys commented 6 years ago

Follow up: I tried using polymer-bundler from the Polymer project and it did exactly what I wanted: create a single file containing api-console and all of its dependencies that works as expected. I am closing this issue since I was able to find an alternative solution.