-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3124f1f
commit b1b6bef
Showing
6 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,5 @@ test/cov_profile | |
coverage.lcov | ||
|
||
# Build output | ||
deno_cache/ | ||
out/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import {bundle} from "https://deno.land/x/[email protected]/mod.ts"; | ||
import {createCache} from "https://deno.land/x/[email protected]/mod.ts"; | ||
|
||
// Parse args | ||
const [release, source = `https://deno.land/x/grammy@${release}/mod.ts`] = Deno.args; | ||
if (!release) throw new Error("No release specified!"); | ||
|
||
// Rewrite imports from .deno.ts to .web.ts | ||
const cache = createCache(); | ||
const load = (specifier: string) => { | ||
if (specifier.endsWith(".deno.ts")) { | ||
const baseLength = specifier.length - ".deno.ts".length; | ||
specifier = specifier.substring(0, baseLength) + ".web.ts"; | ||
console.log(specifier); | ||
} | ||
return cache.load(specifier); | ||
}; | ||
|
||
console.log(`Bundling version '${release}' from ${source} ...`); | ||
// Bundle code | ||
const {code: bundledCode} = await bundle( | ||
"../src/mod.ts", | ||
{ | ||
load, | ||
compilerOptions: { | ||
sourceMap: false, | ||
inlineSources: false, | ||
inlineSourceMap: false, | ||
} | ||
} | ||
); | ||
|
||
console.log("Emitting ..."); | ||
// Strip the huge inline source map which is somehow generated anyway | ||
await Deno.writeTextFile( | ||
"../out/web.mjs", | ||
bundledCode.replace(/\/\/# sourceMappingURL=.*\n/, ""), | ||
); | ||
await Deno.writeTextFile( | ||
"../out/web.d.ts", | ||
'export * from "./mod";\n', | ||
); | ||
|
||
console.log("Done."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export { | ||
delistify, | ||
GLOBAL_CONSTRUCTOR_MAP, | ||
listify, | ||
} from "https://deno.land/x/[email protected]/mod.ts"; | ||
export * from "https://lib.deno.dev/x/grammy@v1/mod.ts"; | ||
export * from "https://lib.deno.dev/x/grammy@v1/types.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters