Skip to content

Commit

Permalink
Remove dynamic import ponyfill
Browse files Browse the repository at this point in the history
Remove the dynamic import ponyfill now that browser support
is much improved. It's natively supported in the four major
browsers.

Add browser support note to the readme as well to outline our
policy, advising users to keep their browsers up to date.
  • Loading branch information
AlanGreene authored and tekton-robot committed Apr 21, 2020
1 parent 105c00b commit 7bbdda6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 39 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@ You can access the web UI at `http://localhost:9097/`

The Dashboard can be uninstalled on Minishift by running the command `./minishift-delete-dashboard.sh` Use `-n {NAMESPACE}` on the end of the command if installed into a namespace other than `tekton-pipelines`

## Browser support

The Dashboard has been tested on modern evergreen browsers, and generally supports the current and previous stable versions of:

- Google Chrome (Windows, macOS, Linux)
- Mozilla Firefox (Windows, macOS, Linux)
- Apple Safari (macOS)
- Microsoft Edge (Windows)

Older versions or other browsers may work, but some features may be missing or not function as expected.

## Troubleshooting

Keep in mind that When running your Tekton Pipelines, if you see a `fatal: could not read Username for *GitHub repository*: No such device or address` message in your failing Task logs, this indicates there is no `tekton.dev/git` annotated GitHub secret in use by the ServiceAccount that launched this PipelineRun. It is advised to create one through the Tekton Dashboard. The annotation will be added and the specified ServiceAccount will be patched.
Expand Down
41 changes: 2 additions & 39 deletions src/containers/Extension/Extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,50 +20,13 @@ import * as actions from './actions';
import * as selectors from '../../reducers';
import './globals';

/* istanbul ignore next */
function dynamicImport(source, name) {
return new Promise((resolve, reject) => {
const script = document.createElement('script');
const moduleId = `__tektonDashboardExtension_${name}`;

const cleanup = () => {
script.remove();
URL.revokeObjectURL(script.src);
delete window[moduleId];
};

script.type = 'module';
script.crossorigin = 'anonymous'; // sets credentials flag to 'same-origin'
script.onerror = () => {
reject(new Error(`Failed to import ${source}`));
cleanup();
};

script.onload = () => {
resolve({ default: window[moduleId] });
cleanup();
};

const loaderModule = `import extension from '${source}'; window['${moduleId}'] = extension;`;
const loaderBlob = new Blob([loaderModule], { type: 'text/javascript' });
script.src = URL.createObjectURL(loaderBlob);

document.head.appendChild(script);
});
}

/* istanbul ignore next */ class Extension extends Component {
constructor(props) {
super(props);

const { name, source } = props;
const { source } = props;
const ExtensionComponent = React.lazy(() => {
try {
return new Function(`return import("${source}")`)(); // eslint-disable-line no-new-func
} catch (e) {
console.warn('dynamic module import not supported, trying fallback'); // eslint-disable-line no-console
return dynamicImport(source, name);
}
return import(/* webpackIgnore: true */ source);
});

this.state = { ExtensionComponent };
Expand Down

0 comments on commit 7bbdda6

Please sign in to comment.