Skip to content

Commit

Permalink
✨ Add the external option
Browse files Browse the repository at this point in the history
  • Loading branch information
takker99 committed Nov 11, 2021
1 parent 0ac3d48 commit 00fde6d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ export const remoteLoader = (
({ path, importer }) => {
if (skip(path)) return { external: true };
const resolvedPath = importMap.imports?.[path] ?? path;
if (skip(path)) return { external: true };
if (skip(resolvedPath)) return { external: true };

if (resolvedPath.startsWith("http")) {
console.log(`(${path}, ${importer}) -> ${resolvedPath}`);
console.log(`(${path}) -> ${resolvedPath}`);
return {
path: decodeURI(resolvedPath),
namespace: name,
};
}
importer = importer === "<stdin>" ? baseURL.toString() : importer;
const importURL = new URL(resolvedPath, importer).toString();
if (skip(path)) return { external: true };
if (skip(importURL)) return { external: true };
if (importURL.startsWith("http")) {
console.log(`(${resolvedPath}, ${importer}) -> ${importURL}`);
return {
Expand Down
2 changes: 2 additions & 0 deletions parseParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ export function parseSearchParams(searchParam: string): ParamOptions {
const entryURL = params.get("url") ?? "";
const reload = params.get("reload") === null ? false : true;
const sourcemap = params.get("sourcemap") === null ? false : "inline";
const external = params.getAll("external");

return {
bundle,
minify,
format: isFormat(format) ? format : "esm",
charset,
entryURL,
external,
run,
jsxFactory,
jsxFragment,
Expand Down
1 change: 1 addition & 0 deletions types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export type BundleOptions = {
charset?: "utf8";
format: Format;
entryURL: string;
external: string[];
jsxFactory: string;
jsxFragment: string;
reload: boolean;
Expand Down

0 comments on commit 00fde6d

Please sign in to comment.