|
1 | 1 | import { build, emptyDir } from "@deno/dnt"; |
2 | | -import { rollup } from "npm:rollup"; |
3 | | -import resolve from "npm:@rollup/plugin-node-resolve"; |
4 | | -import commonjs from "npm:@rollup/plugin-commonjs"; |
5 | | -import { terser } from "npm:rollup-plugin-terser"; |
6 | | - |
7 | | -async function bundleForBrowser() { |
8 | | - console.log("Bundling for browser..."); |
9 | | - const bundle = await rollup({ |
10 | | - input: "npm/esm/main.js", |
11 | | - plugins: [ |
12 | | - resolve({ browser: true, preferBuiltins: false }), |
13 | | - commonjs(), |
14 | | - terser(), |
15 | | - ], |
16 | | - logLevel: 'debug', |
17 | | - }); |
18 | | - |
19 | | - console.log("Writing to npm/dist/bundle.js"); |
20 | | - await bundle.write({ |
21 | | - file: "npm/dist/bundle.js", |
22 | | - format: "esm", |
23 | | - sourcemap: true, |
24 | | - }); |
25 | | - console.log("Closing Rollup"); |
26 | | - await bundle.close(); |
27 | | -} |
28 | | - |
29 | 2 | await emptyDir("./npm"); |
30 | 3 |
|
31 | 4 | const { version, description } = JSON.parse(Deno.readTextFileSync("deno.json")); |
@@ -53,13 +26,12 @@ await build({ |
53 | 26 | url: "https://github.com/scrapfly/typescript-scrapfly/issues", |
54 | 27 | }, |
55 | 28 | homepage: "https://scrapfly.io/", |
56 | | - main: "./esm/src/main.js", // Point to the ESM output |
57 | | - types: "./esm/src/main.d.ts", // Point to the TypeScript declarations |
| 29 | + main: "./esm/main.js", |
| 30 | + types: "./esm/main.d.ts", |
58 | 31 | }, |
59 | 32 | postBuild: async () => { |
60 | 33 | Deno.copyFileSync("LICENSE", "npm/LICENSE"); |
61 | 34 | Deno.copyFileSync("README.md", "npm/README.md"); |
62 | | - await bundleForBrowser(); |
63 | 35 | }, |
64 | 36 | }); |
65 | 37 |
|
|
0 commit comments