@hypernym/bundler 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,7 +25,7 @@ const externals = [
25
25
  ];
26
26
 
27
27
  const name = "bundler";
28
- const version = `0.1.1`;
28
+ const version = `0.1.2`;
29
29
 
30
30
  const cl = console.log;
31
31
  const log = (...args) => {
@@ -260,7 +260,7 @@ async function build(cwd, options) {
260
260
  buildStats.size = buildStats.size + stats.size;
261
261
  }
262
262
  if ("types" in entry) {
263
- const { types, plugins } = entry;
263
+ const { types, externals, plugins, banner, footer } = entry;
264
264
  const buildLogs = [];
265
265
  const _output = getOutputPath(outDir, types, true);
266
266
  let _format = "esm";
@@ -270,6 +270,7 @@ async function build(cwd, options) {
270
270
  const format = entry.format || _format;
271
271
  const builder = await rollup({
272
272
  input: resolve(cwd, types),
273
+ external: externals || options.externals,
273
274
  plugins: [dts(plugins?.dts)],
274
275
  onLog: (level, log) => {
275
276
  if (logFilter(log))
@@ -278,7 +279,9 @@ async function build(cwd, options) {
278
279
  });
279
280
  await builder.write({
280
281
  file: resolve(cwd, output),
281
- format
282
+ format,
283
+ banner,
284
+ footer
282
285
  });
283
286
  const stats = await stat(resolve(cwd, output));
284
287
  buildStats.files.push({
@@ -13,23 +13,74 @@ interface BuildPlugins {
13
13
  replace?: RollupReplaceOptions;
14
14
  }
15
15
 
16
- interface Entries {
16
+ interface Entry {
17
+ /**
18
+ * Specifies the path of the transformed module.
19
+ *
20
+ * If not specified, matches the `input` path with the appropriate extension.
21
+ *
22
+ * @default undefined
23
+ */
17
24
  output?: string;
25
+ /**
26
+ * Specifies the format of the generated module.
27
+ *
28
+ * @default 'esm'
29
+ */
18
30
  format?: OutputOptions['format'];
31
+ /**
32
+ * Specifies the module IDs, or regular expressions to match module IDs,
33
+ * that should remain external to the bundle.
34
+ *
35
+ * If not specified, infers the IDs from the global `options.externals` option.
36
+ *
37
+ * @default undefined
38
+ */
19
39
  externals?: (string | RegExp)[];
40
+ /**
41
+ * Specifies the string to be inserted at the beginning of the module.
42
+ *
43
+ * @default undefined
44
+ */
45
+ banner?: OutputOptions['banner'];
46
+ /**
47
+ * Specifies the string to be inserted at the end of the module.
48
+ *
49
+ * @default undefined
50
+ */
51
+ footer?: OutputOptions['footer'];
52
+ /**
53
+ * Specifies custom filters that will display only certain log messages.
54
+ *
55
+ * @default undefined
56
+ */
20
57
  logFilter?: string[];
21
58
  }
22
- interface EntriesInput extends Entries {
59
+ interface EntryInput extends Entry {
60
+ /**
61
+ * Specifies the path of the module's build source.
62
+ */
23
63
  input: string;
24
- banner?: OutputOptions['banner'];
25
- footer?: OutputOptions['footer'];
64
+ /**
65
+ * Specifies plugin options.
66
+ *
67
+ * @default undefined
68
+ */
26
69
  plugins?: BuildPlugins;
27
70
  }
28
- interface EntriesTypes extends Entries {
71
+ interface EntryTypes extends Entry {
72
+ /**
73
+ * Specifies the path of the module's build source that contains only TS definitions.
74
+ */
29
75
  types: string;
76
+ /**
77
+ * Specifies plugin options.
78
+ *
79
+ * @default undefined
80
+ */
30
81
  plugins?: Pick<BuildPlugins, 'dts'>;
31
82
  }
32
- type EntriesOptions = EntriesInput | EntriesTypes;
83
+ type EntriesOptions = EntryInput | EntryTypes;
33
84
 
34
85
  interface BuildHooks {
35
86
  /**
@@ -59,6 +110,10 @@ interface Options {
59
110
  * Specifies the module IDs, or regular expressions to match module IDs,
60
111
  * that should remain external to the bundle.
61
112
  *
113
+ * IDs and regexps from this option are applied globally to all entries.
114
+ *
115
+ * Also, it is possible to define externals individually per entry (`entry.externals`).
116
+ *
62
117
  * @default [/^node:/, /^@types/, /^@rollup/, /^@hypernym/, /^rollup/, ...pkg.dependencies]
63
118
  */
64
119
  externals?: (string | RegExp)[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypernym/bundler",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "author": "Hypernym Studio",
5
5
  "description": "ESM & TS module bundler.",
6
6
  "license": "MIT",