prebundle 0.0.3 → 1.0.0
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.
- package/README.md +72 -45
- package/dist/index.d.ts +1 -0
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Prebundle
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Prebundle 3rd party dependencies, output a single js file, a package.json file and the dts files.
|
|
4
|
+
|
|
5
|
+
Based on [ncc](https://github.com/vercel/ncc) and `dts-packer`.
|
|
6
|
+
|
|
7
|
+
<p>
|
|
8
|
+
<a href="https://npmjs.com/package/prebundle">
|
|
9
|
+
<img src="https://img.shields.io/npm/v/prebundle?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" />
|
|
10
|
+
</a>
|
|
11
|
+
<img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="license" />
|
|
12
|
+
</p>
|
|
4
13
|
|
|
5
14
|
## Motivation
|
|
6
15
|
|
|
@@ -36,14 +45,17 @@ Supported dependency config:
|
|
|
36
45
|
Externals to leave as requires of the build.
|
|
37
46
|
|
|
38
47
|
```ts
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
48
|
+
// prebundle.config.mjs
|
|
49
|
+
export default {
|
|
50
|
+
dependencies: [
|
|
51
|
+
{
|
|
52
|
+
name: 'foo',
|
|
53
|
+
externals: {
|
|
54
|
+
webpack: '../webpack',
|
|
55
|
+
},
|
|
44
56
|
},
|
|
45
|
-
|
|
46
|
-
|
|
57
|
+
],
|
|
58
|
+
};
|
|
47
59
|
```
|
|
48
60
|
|
|
49
61
|
### minify
|
|
@@ -51,12 +63,15 @@ dependencies: [
|
|
|
51
63
|
Whether to minify the code, default `true`.
|
|
52
64
|
|
|
53
65
|
```ts
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
66
|
+
// prebundle.config.mjs
|
|
67
|
+
export default {
|
|
68
|
+
dependencies: [
|
|
69
|
+
{
|
|
70
|
+
name: 'foo',
|
|
71
|
+
minify: false,
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
};
|
|
60
75
|
```
|
|
61
76
|
|
|
62
77
|
### packageJsonField
|
|
@@ -64,12 +79,15 @@ dependencies: [
|
|
|
64
79
|
Copy extra fields from original package.json to target package.json.
|
|
65
80
|
|
|
66
81
|
```ts
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
]
|
|
82
|
+
// prebundle.config.mjs
|
|
83
|
+
export default {
|
|
84
|
+
dependencies: [
|
|
85
|
+
{
|
|
86
|
+
name: 'foo',
|
|
87
|
+
packageJsonField: ['options'],
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
};
|
|
73
91
|
```
|
|
74
92
|
|
|
75
93
|
Following fields will be copied by default:
|
|
@@ -88,14 +106,17 @@ Following fields will be copied by default:
|
|
|
88
106
|
Callback before bundle.
|
|
89
107
|
|
|
90
108
|
```ts
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
109
|
+
// prebundle.config.mjs
|
|
110
|
+
export default {
|
|
111
|
+
dependencies: [
|
|
112
|
+
{
|
|
113
|
+
name: 'foo',
|
|
114
|
+
beforeBundle(task) {
|
|
115
|
+
console.log('do something');
|
|
116
|
+
},
|
|
96
117
|
},
|
|
97
|
-
|
|
98
|
-
|
|
118
|
+
],
|
|
119
|
+
};
|
|
99
120
|
```
|
|
100
121
|
|
|
101
122
|
### emitFiles
|
|
@@ -103,17 +124,20 @@ dependencies: [
|
|
|
103
124
|
Emit extra entry files to map imports.
|
|
104
125
|
|
|
105
126
|
```ts
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
]
|
|
127
|
+
// prebundle.config.mjs
|
|
128
|
+
export default {
|
|
129
|
+
dependencies: [
|
|
130
|
+
{
|
|
131
|
+
name: 'foo',
|
|
132
|
+
emitFiles: [
|
|
133
|
+
{
|
|
134
|
+
path: 'foo.js',
|
|
135
|
+
content: `module.exports = require('./').foo;`,
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
};
|
|
117
141
|
```
|
|
118
142
|
|
|
119
143
|
### ignoreDts
|
|
@@ -123,10 +147,13 @@ Ignore the original .d.ts declaration file, then generate a fake .d.ts file.
|
|
|
123
147
|
This can be used to reduce file size for the packages that do not require type definitions, such as webpack plugin.
|
|
124
148
|
|
|
125
149
|
```ts
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
150
|
+
// prebundle.config.mjs
|
|
151
|
+
export default {
|
|
152
|
+
dependencies: [
|
|
153
|
+
{
|
|
154
|
+
name: 'foo',
|
|
155
|
+
ignoreDts: true,
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
};
|
|
132
159
|
```
|
package/dist/index.d.ts
CHANGED
package/package.json
CHANGED