// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
import { loadLazyBundle } from './lazy-bundle.js';
export function loadDynamicJS(url) {
    if (__LEPUS__) {
        _ReportError(new Error(`A dynamic import (to "${url}") is leaked to Lepus bundle.`), { errorCode: 202 });
        // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
        return Promise.reject();
    }
    return new Promise((resolve, reject) => {
        lynx.requireModuleAsync(url, (err, data) => {
            if (err) {
                reject(err);
            }
            else {
                resolve(data);
            }
        });
    });
}
export function __dynamicImport(url, options) {
    const t = options?.with?.type;
    if (t === 'component' || t === 'tsx' || t === 'jsx') {
        return loadLazyBundle(url);
    }
    else {
        return loadDynamicJS(url);
    }
}
//# sourceMappingURL=dynamic-import.js.map