@forge/bundler 3.1.0-test.8 → 3.1.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/CHANGELOG.md CHANGED
@@ -1,10 +1,455 @@
1
1
  # @forge/bundler
2
2
 
3
- ## 3.1.0-test.8
3
+ ## 3.1.0
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - d68934c: fake fix a
7
+ - 89ae99e: Add support for auto-bundling resources
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [3c0ac54]
12
+ - Updated dependencies [89ae99e]
13
+ - @forge/lint@3.2.4
14
+ - @forge/cli-shared@3.1.0
15
+
16
+ ## 3.1.0-next.4
17
+
18
+ ### Patch Changes
19
+
20
+ - @forge/lint@3.2.4-next.4
21
+
22
+ ## 3.1.0-next.3
23
+
24
+ ### Patch Changes
25
+
26
+ - @forge/cli-shared@3.1.0-next.2
27
+ - @forge/lint@3.2.4-next.3
28
+
29
+ ## 3.1.0-next.2
30
+
31
+ ### Patch Changes
32
+
33
+ - Updated dependencies [3c0ac54]
34
+ - @forge/lint@3.2.4-next.2
35
+
36
+ ## 3.1.0-next.1
37
+
38
+ ### Patch Changes
39
+
40
+ - @forge/cli-shared@3.1.0-next.1
41
+ - @forge/lint@3.2.4-next.1
42
+
43
+ ## 3.1.0-next.0
44
+
45
+ ### Minor Changes
46
+
47
+ - 89ae99e0: Add support for auto-bundling resources
48
+
49
+ ### Patch Changes
50
+
51
+ - Updated dependencies [89ae99e0]
52
+ - @forge/cli-shared@3.1.0-next.0
53
+ - @forge/lint@3.2.4-next.0
54
+
55
+ ## 3.0.12
56
+
57
+ ### Patch Changes
58
+
59
+ - Updated dependencies [5424f97]
60
+ - Updated dependencies [35172f2]
61
+ - Updated dependencies [edab85a]
62
+ - Updated dependencies [5972825c]
63
+ - @forge/cli-shared@3.0.0
64
+ - @forge/lint@3.2.3
65
+
66
+ ## 3.0.12-next.3
67
+
68
+ ### Patch Changes
69
+
70
+ - Updated dependencies [5424f97]
71
+ - @forge/cli-shared@3.0.0-next.3
72
+ - @forge/lint@3.2.3-next.3
73
+
74
+ ## 3.0.12-next.2
75
+
76
+ ### Patch Changes
77
+
78
+ - Updated dependencies [35172f2]
79
+ - @forge/cli-shared@3.0.0-next.2
80
+ - @forge/lint@3.2.3-next.2
81
+
82
+ ## 3.0.12-next.1
83
+
84
+ ### Patch Changes
85
+
86
+ - @forge/cli-shared@3.0.0-next.1
87
+ - @forge/lint@3.2.3-next.1
88
+
89
+ ## 3.0.12-next.0
90
+
91
+ ### Patch Changes
92
+
93
+ - Updated dependencies [edab85a5]
94
+ - Updated dependencies [5972825c]
95
+ - @forge/cli-shared@3.0.0-next.0
96
+ - @forge/lint@3.2.3-next.0
97
+
98
+ ## 3.0.11
99
+
100
+ ### Patch Changes
101
+
102
+ - @forge/cli-shared@2.6.2
103
+ - @forge/lint@3.2.2
104
+
105
+ ## 3.0.11-next.5
106
+
107
+ ### Patch Changes
108
+
109
+ - @forge/cli-shared@2.6.2-next.5
110
+ - @forge/lint@3.2.2-next.5
111
+
112
+ ## 3.0.11-next.4
113
+
114
+ ### Patch Changes
115
+
116
+ - @forge/cli-shared@2.6.2-next.4
117
+ - @forge/lint@3.2.2-next.4
118
+
119
+ ## 3.0.11-next.3
120
+
121
+ ### Patch Changes
122
+
123
+ - @forge/cli-shared@2.6.2-next.3
124
+ - @forge/lint@3.2.2-next.3
125
+
126
+ ## 3.0.11-next.2
127
+
128
+ ### Patch Changes
129
+
130
+ - @forge/cli-shared@2.6.2-next.2
131
+ - @forge/lint@3.2.2-next.2
132
+
133
+ ## 3.0.11-next.1
134
+
135
+ ### Patch Changes
136
+
137
+ - @forge/cli-shared@2.6.2-next.1
138
+ - @forge/lint@3.2.2-next.1
139
+
140
+ ## 3.0.11-next.0
141
+
142
+ ### Patch Changes
143
+
144
+ - @forge/cli-shared@2.6.2-next.0
145
+ - @forge/lint@3.2.2-next.0
146
+
147
+ ## 3.0.10
148
+
149
+ ### Patch Changes
150
+
151
+ - 13f2ae81: Created a new bundler for the node runtime
152
+ - @forge/cli-shared@2.6.1
153
+ - @forge/lint@3.2.1
154
+
155
+ ## 3.0.10-next.6
156
+
157
+ ### Patch Changes
158
+
159
+ - @forge/cli-shared@2.6.1-next.6
160
+ - @forge/lint@3.2.1-next.6
161
+
162
+ ## 3.0.10-next.5
163
+
164
+ ### Patch Changes
165
+
166
+ - @forge/cli-shared@2.6.1-next.5
167
+ - @forge/lint@3.2.1-next.5
168
+
169
+ ## 3.0.10-next.4
170
+
171
+ ### Patch Changes
172
+
173
+ - @forge/cli-shared@2.6.1-next.4
174
+ - @forge/lint@3.2.1-next.4
175
+
176
+ ## 3.0.10-next.3
177
+
178
+ ### Patch Changes
179
+
180
+ - @forge/cli-shared@2.6.1-next.3
181
+ - @forge/lint@3.2.1-next.3
182
+
183
+ ## 3.0.10-next.2
184
+
185
+ ### Patch Changes
186
+
187
+ - 13f2ae81: Created a new bundler for the node runtime
188
+ - @forge/cli-shared@2.6.1-next.2
189
+ - @forge/lint@3.2.1-next.2
190
+
191
+ ## 3.0.10-next.1
192
+
193
+ ### Patch Changes
194
+
195
+ - @forge/cli-shared@2.6.1-next.1
196
+ - @forge/lint@3.2.1-next.1
197
+
198
+ ## 3.0.10-next.0
199
+
200
+ ### Patch Changes
201
+
202
+ - @forge/cli-shared@2.6.1-next.0
203
+ - @forge/lint@3.2.1-next.0
204
+
205
+ ## 3.0.9
206
+
207
+ ### Patch Changes
208
+
209
+ - e0f6a1c: Refactored bundler creation into a factory function
210
+ - Updated dependencies [7fe19b4]
211
+ - Updated dependencies [69f42bd]
212
+ - Updated dependencies [8309725]
213
+ - @forge/lint@3.2.0
214
+ - @forge/cli-shared@2.6.0
215
+
216
+ ## 3.0.9-next.6
217
+
218
+ ### Patch Changes
219
+
220
+ - Updated dependencies [8309725]
221
+ - @forge/lint@3.2.0-next.5
222
+
223
+ ## 3.0.9-next.5
224
+
225
+ ### Patch Changes
226
+
227
+ - Updated dependencies [7fe19b40]
228
+ - @forge/lint@3.1.3-next.4
229
+
230
+ ## 3.0.9-next.4
231
+
232
+ ### Patch Changes
233
+
234
+ - @forge/cli-shared@2.6.0-next.3
235
+ - @forge/lint@3.1.3-next.3
236
+
237
+ ## 3.0.9-next.3
238
+
239
+ ### Patch Changes
240
+
241
+ - @forge/cli-shared@2.6.0-next.2
242
+ - @forge/lint@3.1.3-next.2
243
+
244
+ ## 3.0.9-next.2
245
+
246
+ ### Patch Changes
247
+
248
+ - @forge/cli-shared@2.6.0-next.1
249
+ - @forge/lint@3.1.3-next.1
250
+
251
+ ## 3.0.9-next.1
252
+
253
+ ### Patch Changes
254
+
255
+ - e0f6a1c9: Refactored bundler creation into a factory function
256
+
257
+ ## 3.0.9-next.0
258
+
259
+ ### Patch Changes
260
+
261
+ - Updated dependencies [69f42bdc]
262
+ - @forge/cli-shared@2.6.0-next.0
263
+ - @forge/lint@3.1.3-next.0
264
+
265
+ ## 3.0.8
266
+
267
+ ### Patch Changes
268
+
269
+ - @forge/cli-shared@2.5.1
270
+ - @forge/lint@3.1.2
271
+
272
+ ## 3.0.8-next.2
273
+
274
+ ### Patch Changes
275
+
276
+ - @forge/cli-shared@2.5.1-next.1
277
+ - @forge/lint@3.1.2-next.2
278
+
279
+ ## 3.0.8-next.1
280
+
281
+ ### Patch Changes
282
+
283
+ - @forge/cli-shared@2.5.1-next.0
284
+ - @forge/lint@3.1.2-next.1
285
+
286
+ ## 3.0.8-next.0
287
+
288
+ ### Patch Changes
289
+
290
+ - @forge/lint@3.1.2-next.0
291
+
292
+ ## 3.0.7
293
+
294
+ ### Patch Changes
295
+
296
+ - Updated dependencies [b3ee297]
297
+ - Updated dependencies [4f86661]
298
+ - Updated dependencies [6d7a574e]
299
+ - @forge/api@2.7.0
300
+ - @forge/cli-shared@2.5.0
301
+ - @forge/lint@3.1.1
302
+
303
+ ## 3.0.7-next.4
304
+
305
+ ### Patch Changes
306
+
307
+ - Updated dependencies [b3ee2973]
308
+ - @forge/api@2.7.0-next.0
309
+
310
+ ## 3.0.7-next.3
311
+
312
+ ### Patch Changes
313
+
314
+ - Updated dependencies [4f86661c]
315
+ - @forge/cli-shared@2.5.0-next.3
316
+ - @forge/lint@3.1.1-next.3
317
+
318
+ ## 3.0.7-next.2
319
+
320
+ ### Patch Changes
321
+
322
+ - @forge/cli-shared@2.5.0-next.2
323
+ - @forge/lint@3.1.1-next.2
324
+
325
+ ## 3.0.7-next.1
326
+
327
+ ### Patch Changes
328
+
329
+ - @forge/cli-shared@2.5.0-next.1
330
+ - @forge/lint@3.1.1-next.1
331
+
332
+ ## 3.0.7-next.0
333
+
334
+ ### Patch Changes
335
+
336
+ - Updated dependencies [6d7a574]
337
+ - @forge/cli-shared@2.5.0-next.0
338
+ - @forge/lint@3.1.1-next.0
339
+
340
+ ## 3.0.6
341
+
342
+ ### Patch Changes
343
+
344
+ - Updated dependencies [ce4a65f]
345
+ - @forge/lint@3.1.0
346
+ - @forge/cli-shared@2.4.2
347
+
348
+ ## 3.0.6-next.1
349
+
350
+ ### Patch Changes
351
+
352
+ - Updated dependencies [ce4a65f]
353
+ - @forge/lint@3.1.0-next.1
354
+ - @forge/cli-shared@2.4.2-next.1
355
+
356
+ ## 3.0.6-next.0
357
+
358
+ ### Patch Changes
359
+
360
+ - @forge/cli-shared@2.4.2-next.0
361
+ - @forge/lint@3.0.6-next.0
362
+
363
+ ## 3.0.5
364
+
365
+ ### Patch Changes
366
+
367
+ - a471568: Patching libs due to npm issue
368
+
369
+ ## 3.0.5-next.0
370
+
371
+ ### Patch Changes
372
+
373
+ - a4715681: Patching libs due to npm issue
374
+
375
+ ## 3.0.4
376
+
377
+ ### Patch Changes
378
+
379
+ - @forge/cli-shared@2.4.1
380
+ - @forge/lint@3.0.5
381
+
382
+ ## 3.0.4-next.7
383
+
384
+ ### Patch Changes
385
+
386
+ - @forge/cli-shared@2.4.1-next.7
387
+ - @forge/lint@3.0.5-next.7
388
+
389
+ ## 3.0.4-next.6
390
+
391
+ ### Patch Changes
392
+
393
+ - @forge/cli-shared@2.4.1-next.6
394
+ - @forge/lint@3.0.5-next.6
395
+
396
+ ## 3.0.4-next.5
397
+
398
+ ### Patch Changes
399
+
400
+ - @forge/cli-shared@2.4.1-next.5
401
+ - @forge/lint@3.0.5-next.5
402
+
403
+ ## 3.0.4-next.4
404
+
405
+ ### Patch Changes
406
+
407
+ - @forge/cli-shared@2.4.1-next.4
408
+ - @forge/lint@3.0.5-next.4
409
+
410
+ ## 3.0.4-next.3
411
+
412
+ ### Patch Changes
413
+
414
+ - @forge/cli-shared@2.4.1-next.3
415
+ - @forge/lint@3.0.5-next.3
416
+
417
+ ## 3.0.4-next.2
418
+
419
+ ### Patch Changes
420
+
421
+ - @forge/cli-shared@2.4.1-next.2
422
+ - @forge/lint@3.0.5-next.2
423
+
424
+ ## 3.0.4-next.1
425
+
426
+ ### Patch Changes
427
+
428
+ - @forge/cli-shared@2.4.1-next.1
429
+ - @forge/lint@3.0.5-next.1
430
+
431
+ ## 3.0.4-next.0
432
+
433
+ ### Patch Changes
434
+
435
+ - @forge/cli-shared@2.4.1-next.0
436
+ - @forge/lint@3.0.5-next.0
437
+
438
+ ## 3.0.3
439
+
440
+ ### Patch Changes
441
+
442
+ - Updated dependencies [f33aada]
443
+ - Updated dependencies [726ef79]
444
+ - @forge/cli-shared@2.4.0
445
+ - @forge/lint@3.0.4
446
+
447
+ ## 3.0.3-next.8
448
+
449
+ ### Patch Changes
450
+
451
+ - @forge/cli-shared@2.4.0-next.8
452
+ - @forge/lint@3.0.4-next.8
8
453
 
9
454
  ## 3.0.3-next.7
10
455
 
@@ -0,0 +1,4 @@
1
+ import { Configuration as WebpackConfig } from 'webpack';
2
+ import { ConfigBuilder, EntryPoints } from '../webpack';
3
+ export declare const getNativeUiBuildConfig: (entrypoints: EntryPoints, config: ConfigBuilder) => WebpackConfig;
4
+ //# sourceMappingURL=nativeui-webpack-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nativeui-webpack-config.d.ts","sourceRoot":"","sources":["../../src/bundler-config/nativeui-webpack-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAMxD,eAAO,MAAM,sBAAsB,qCAAsC,aAAa,KAAG,aAsExF,CAAC"}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNativeUiBuildConfig = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const path_1 = require("path");
6
+ const webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
7
+ const html_webpack_plugin_1 = tslib_1.__importDefault(require("html-webpack-plugin"));
8
+ const tmp_1 = tslib_1.__importDefault(require("tmp"));
9
+ exports.getNativeUiBuildConfig = (entrypoints, config) => {
10
+ const resolvedEntryPoints = {};
11
+ for (const entrypoint of entrypoints) {
12
+ resolvedEntryPoints[entrypoint.name] = path_1.resolve(entrypoint.path);
13
+ }
14
+ return {
15
+ entry: Object.assign({}, resolvedEntryPoints),
16
+ mode: 'production',
17
+ devtool: 'source-map',
18
+ output: {
19
+ filename: '[name].js',
20
+ path: tmp_1.default.dirSync().name
21
+ },
22
+ node: {
23
+ __dirname: true
24
+ },
25
+ plugins: [
26
+ new html_webpack_plugin_1.default({
27
+ filename: 'index.html'
28
+ }),
29
+ new webpack_bundle_analyzer_1.BundleAnalyzerPlugin({ analyzerMode: 'disabled', generateStatsFile: true })
30
+ ],
31
+ resolve: {
32
+ extensions: ['.ts', '.tsx', '.js', '.jsx', '.jpg', '.jpeg', '.png', '.gif', '.svg']
33
+ },
34
+ resolveLoader: {
35
+ modules: require.resolve.paths('babel-loader') || undefined
36
+ },
37
+ target: 'web',
38
+ module: {
39
+ rules: [
40
+ {
41
+ test: /\.(jpe?g|png|gif|svg)$/i,
42
+ loader: 'file-loader',
43
+ options: {
44
+ name: '[name].[contenthash].[ext]',
45
+ outputPath: 'assets'
46
+ }
47
+ },
48
+ { test: /\.tsx?$/, loader: 'ts-loader' },
49
+ {
50
+ test: /\.jsx?$/,
51
+ exclude: /node_modules/,
52
+ use: [
53
+ {
54
+ loader: 'babel-loader',
55
+ options: {
56
+ plugins: [
57
+ [
58
+ require.resolve('@babel/plugin-transform-react-jsx'),
59
+ {
60
+ pragma: 'React.createElement'
61
+ }
62
+ ],
63
+ require.resolve('@babel/plugin-proposal-numeric-separator'),
64
+ require.resolve('@babel/plugin-proposal-class-properties'),
65
+ require.resolve('@babel/plugin-proposal-optional-chaining')
66
+ ],
67
+ cacheDirectory: true
68
+ }
69
+ }
70
+ ]
71
+ }
72
+ ]
73
+ }
74
+ };
75
+ };
@@ -0,0 +1,4 @@
1
+ import { Configuration as WebpackConfig } from 'webpack';
2
+ import { ConfigBuilder, EntryPoints } from '../webpack';
3
+ export declare const getNodeRuntimeBuildConfig: (entrypoints: EntryPoints, config: ConfigBuilder) => WebpackConfig;
4
+ //# sourceMappingURL=node-webpack-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-webpack-config.d.ts","sourceRoot":"","sources":["../../src/bundler-config/node-webpack-config.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAElE,OAAO,EAAE,aAAa,EAAE,WAAW,EAA0B,MAAM,YAAY,CAAC;AAEhF,eAAO,MAAM,yBAAyB,qCAAsC,aAAa,KAAG,aAY3F,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNodeRuntimeBuildConfig = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const webpack_1 = tslib_1.__importDefault(require("webpack"));
6
+ const path_1 = require("path");
7
+ const webpack_2 = require("../webpack");
8
+ exports.getNodeRuntimeBuildConfig = (entrypoints, config) => {
9
+ const webpackConfig = webpack_2.getCommonWebpackConfig(entrypoints, config);
10
+ const nodeConfigPlugin = new webpack_1.default.ProvidePlugin({
11
+ api: path_1.resolve(path_1.join(__dirname, '..', 'forge-api')),
12
+ 'global.api': path_1.resolve(path_1.join(__dirname, '..', 'forge-api'))
13
+ });
14
+ webpackConfig.plugins.push(nodeConfigPlugin);
15
+ webpackConfig.target = 'node14';
16
+ return webpackConfig;
17
+ };
@@ -0,0 +1,4 @@
1
+ import { Configuration as WebpackConfig } from 'webpack';
2
+ import { ConfigBuilder, EntryPoints } from '../webpack';
3
+ export declare const getSandboxedRuntimeBuildConfig: (entrypoints: EntryPoints, config: ConfigBuilder) => WebpackConfig;
4
+ //# sourceMappingURL=sandboxed-webpack-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandboxed-webpack-config.d.ts","sourceRoot":"","sources":["../../src/bundler-config/sandboxed-webpack-config.ts"],"names":[],"mappings":"AACA,OAAgB,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAElE,OAAO,EAAE,aAAa,EAAE,WAAW,EAA6C,MAAM,YAAY,CAAC;AA0DnG,eAAO,MAAM,8BAA8B,qCAAsC,aAAa,KAAG,aAsEhG,CAAC"}
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSandboxedRuntimeBuildConfig = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const path_1 = require("path");
6
+ const webpack_1 = tslib_1.__importDefault(require("webpack"));
7
+ const stub_plugin_1 = require("../stub-plugin");
8
+ const webpack_2 = require("../webpack");
9
+ const getCustomModulesAliases = () => {
10
+ return {
11
+ 'browserify-cipher': webpack_2.resolveModulePath('browserify-cipher/browser.js'),
12
+ 'browserify-sign/algos': webpack_2.resolveModulePath('browserify-sign/algos.js'),
13
+ 'browserify-sign': webpack_2.resolveModulePath('browserify-sign/browser/index.js'),
14
+ 'create-ecdh': webpack_2.resolveModulePath('create-ecdh/browser.js'),
15
+ 'create-hash/md5': webpack_2.resolveModulePath('create-hash/md5.js'),
16
+ 'create-hash': webpack_2.resolveModulePath('create-hash/browser.js'),
17
+ 'create-hmac': webpack_2.resolveModulePath('create-hmac/browser.js'),
18
+ 'diffie-hellman': webpack_2.resolveModulePath('diffie-hellman/browser.js'),
19
+ pbkdf2: webpack_2.resolveModulePath('pbkdf2/browser.js'),
20
+ 'public-encrypt': webpack_2.resolveModulePath('public-encrypt/browser.js'),
21
+ randombytes: webpack_2.resolveModulePath('randombytes/browser.js'),
22
+ randomfill: webpack_2.resolveModulePath('randomfill/browser.js'),
23
+ assert: webpack_2.resolveModulePath('assert/'),
24
+ buffer: webpack_2.resolveModulePath('buffer/'),
25
+ console: webpack_2.resolveModulePath('console-browserify'),
26
+ crypto: webpack_2.resolveModulePath('crypto-browserify'),
27
+ events: webpack_2.resolveModulePath('events/'),
28
+ os: webpack_2.resolveModulePath('os-browserify/browser'),
29
+ punycode: webpack_2.resolveModulePath('punycode/'),
30
+ process: webpack_2.resolveModulePath('process/browser.js'),
31
+ string_decoder: webpack_2.resolveModulePath('string_decoder/'),
32
+ timers: webpack_2.resolveModulePath('timers-browserify'),
33
+ url: webpack_2.resolveModulePath('url/'),
34
+ util: webpack_2.resolveModulePath('util/'),
35
+ zlib: webpack_2.resolveModulePath('browserify-zlib'),
36
+ fs: webpack_2.resolveModulePath('memfs'),
37
+ http: webpack_2.resolveModulePath('./http'),
38
+ https: webpack_2.resolveModulePath('./http'),
39
+ path: webpack_2.resolveModulePath('path-browserify'),
40
+ querystring: webpack_2.resolveModulePath('querystring-browser'),
41
+ stream: webpack_2.resolveModulePath('readable-stream'),
42
+ 'supports-color': webpack_2.resolveModulePath('supports-color/index.js')
43
+ };
44
+ };
45
+ exports.getSandboxedRuntimeBuildConfig = (entrypoints, config) => {
46
+ const webpackConfig = webpack_2.getCommonWebpackConfig(entrypoints, config);
47
+ const sandboxedConfigPlugins = [
48
+ new webpack_1.default.ProvidePlugin({
49
+ Buffer: [webpack_2.resolveModulePath('buffer/'), 'Buffer'],
50
+ path: webpack_2.resolveModulePath('path-browserify'),
51
+ querystring: webpack_2.resolveModulePath('querystring-browser'),
52
+ stream: webpack_2.resolveModulePath('readable-stream'),
53
+ TextDecoder: [webpack_2.resolveModulePath('text-encoder-lite'), 'TextDecoderLite'],
54
+ TextEncoder: [webpack_2.resolveModulePath('text-encoder-lite'), 'TextEncoderLite'],
55
+ URL: [webpack_2.resolveModulePath('whatwg-url'), 'URL'],
56
+ URLSearchParams: [webpack_2.resolveModulePath('whatwg-url'), 'URLSearchParams']
57
+ }),
58
+ new stub_plugin_1.StubPlugin({
59
+ modules: [
60
+ 'async_hooks',
61
+ 'child_process',
62
+ 'cluster',
63
+ 'constants',
64
+ 'dgram',
65
+ 'dns',
66
+ 'domain',
67
+ 'http2',
68
+ 'module',
69
+ 'net',
70
+ 'perf_hooks',
71
+ 'readline',
72
+ 'repl',
73
+ 'sys',
74
+ 'tls',
75
+ 'trace_events',
76
+ 'tty',
77
+ 'v8',
78
+ 'vm',
79
+ 'worker_threads'
80
+ ],
81
+ placeholder: 'requestedModule',
82
+ stub: path_1.resolve(__dirname, '..', 'unsupported')
83
+ })
84
+ ];
85
+ sandboxedConfigPlugins.forEach((plugin) => webpackConfig.plugins.push(plugin));
86
+ const moduleRuls = [
87
+ {
88
+ test: /(readable-stream|pbkdf2|util)\//,
89
+ resolve: {
90
+ aliasFields: ['browser']
91
+ }
92
+ },
93
+ {
94
+ test: /axios\//,
95
+ resolve: {
96
+ aliasFields: []
97
+ }
98
+ }
99
+ ];
100
+ moduleRuls.forEach((rule) => webpackConfig.module.rules.push(rule));
101
+ webpackConfig.target = 'webworker';
102
+ webpackConfig.resolve = Object.assign(Object.assign({}, webpackConfig.resolve), { mainFields: ['main', 'module'], exportsFields: [], alias: getCustomModulesAliases() });
103
+ return webpackConfig;
104
+ };
@@ -0,0 +1,7 @@
1
+ import { RequestInfo, RequestInit, Response } from 'node-fetch';
2
+ export declare function fetch(url: RequestInfo, init: RequestInit): Promise<Response>;
3
+ export declare const requestJira: undefined;
4
+ export declare function asApp(): {
5
+ __requestAtlassian: () => void;
6
+ };
7
+ //# sourceMappingURL=forge-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forge-api.d.ts","sourceRoot":"","sources":["../src/forge-api.ts"],"names":[],"mappings":"AAIA,OAAkB,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3E,wBAAsB,KAAK,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAgBlF;AACD,eAAO,MAAM,WAAW,WAAS,CAAC;AAClC,wBAAgB,KAAK,IAAI;IAAE,kBAAkB,EAAE,MAAM,IAAI,CAAA;CAAE,CAE1D"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asApp = exports.requestJira = exports.fetch = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
6
+ async function fetch(url, init) {
7
+ const result = await node_fetch_1.default(url, init);
8
+ return Object.assign(Object.assign({}, result), { json: () => result.json(), clone: () => result.clone(), arrayBuffer: () => result.arrayBuffer(), blob: () => result.blob(), buffer: () => result.buffer(), text: () => result.text(), textConverted: () => result.textConverted() });
9
+ }
10
+ exports.fetch = fetch;
11
+ exports.requestJira = void 0;
12
+ function asApp() {
13
+ return { __requestAtlassian: () => void 0 };
14
+ }
15
+ exports.asApp = asApp;
package/out/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { Bundler, Watcher, WatcherMonitor, BundlerOutput } from './types';
2
- export { bundle, watch } from './webpack';
1
+ export { Bundler, InDiskBundler, Watcher, WatcherMonitor, BundlerOutput } from './types';
2
+ export { sandboxBundle, nodeBundle, nativeUiBundle, watch } from './webpack';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC"}
package/out/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var webpack_1 = require("./webpack");
4
- Object.defineProperty(exports, "bundle", { enumerable: true, get: function () { return webpack_1.bundle; } });
4
+ Object.defineProperty(exports, "sandboxBundle", { enumerable: true, get: function () { return webpack_1.sandboxBundle; } });
5
+ Object.defineProperty(exports, "nodeBundle", { enumerable: true, get: function () { return webpack_1.nodeBundle; } });
6
+ Object.defineProperty(exports, "nativeUiBundle", { enumerable: true, get: function () { return webpack_1.nativeUiBundle; } });
5
7
  Object.defineProperty(exports, "watch", { enumerable: true, get: function () { return webpack_1.watch; } });
package/out/types.d.ts CHANGED
@@ -14,6 +14,9 @@ export interface BundlerOutput {
14
14
  };
15
15
  }
16
16
  export declare type Bundler = (appDirectory: string, endpointPath: EntryPoints) => Promise<BundlerOutput>;
17
+ export declare type InDiskBundler = (appDirectory: string, entrypoints: EntryPoints) => Promise<{
18
+ outputDir: string;
19
+ }>;
17
20
  export declare type WatcherCallback = (err: Error | null, output?: BundlerOutput) => void;
18
21
  export interface WatcherMonitor {
19
22
  stop(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,oBAAY,YAAY,GAAG;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAC1D,oBAAY,gBAAgB,GAAG;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAE9D,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,YAAY,CAAC;IACrB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,QAAQ,CAAC,EAAE;QACT,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH;AAED,oBAAY,OAAO,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;AAElG,oBAAY,eAAe,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;AAClF,MAAM,WAAW,cAAc;IAC7B,IAAI,IAAI,IAAI,CAAC;CACd;AAED,oBAAY,QAAQ,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;AAEpE,oBAAY,OAAO,GAAG,CACpB,YAAY,EAAE,WAAW,EACzB,WAAW,EAAE,OAAO,EACpB,QAAQ,EAAE,eAAe,EACzB,QAAQ,CAAC,EAAE,QAAQ,KAChB,cAAc,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,oBAAY,YAAY,GAAG;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAC1D,oBAAY,gBAAgB,GAAG;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAE9D,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,YAAY,CAAC;IACrB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,QAAQ,CAAC,EAAE;QACT,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH;AAED,oBAAY,OAAO,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;AAClG,oBAAY,aAAa,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,KAAK,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE/G,oBAAY,eAAe,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;AAClF,MAAM,WAAW,cAAc;IAC7B,IAAI,IAAI,IAAI,CAAC;CACd;AAED,oBAAY,QAAQ,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;AAEpE,oBAAY,OAAO,GAAG,CACpB,YAAY,EAAE,WAAW,EACzB,WAAW,EAAE,OAAO,EACpB,QAAQ,EAAE,eAAe,EACzB,QAAQ,CAAC,EAAE,QAAQ,KAChB,cAAc,CAAC"}
package/out/webpack.d.ts CHANGED
@@ -1,15 +1,24 @@
1
- import { Bundler, Watcher } from './types';
1
+ import { Configuration as WebpackConfig, ModuleOptions } from 'webpack';
2
+ import { Bundler, Watcher, InDiskBundler } from './types';
2
3
  export declare type EntryPoints = Array<{
3
4
  name: string;
4
5
  path: string;
5
6
  }>;
6
- interface ConfigBuilder {
7
+ export declare const resolveModulePath: (moduleName: string) => string;
8
+ export declare const getDevToolConfig: (config: ConfigBuilder) => string;
9
+ declare type RequiredFields<T, F extends keyof T> = T & Required<Pick<T, F>>;
10
+ declare type CommonModuleOptions = RequiredFields<ModuleOptions, 'rules'>;
11
+ declare type CommonWebpackConfig = RequiredFields<WebpackConfig, 'plugins' | 'module'> & Record<'module', CommonModuleOptions>;
12
+ export declare const getCommonWebpackConfig: (entrypoints: EntryPoints, config: ConfigBuilder) => CommonWebpackConfig;
13
+ export interface ConfigBuilder {
7
14
  isWatchMode: boolean;
8
15
  isDebugMode?: boolean;
9
16
  appDirectory: string;
10
17
  }
11
- export declare const getDevToolConfig: (config: ConfigBuilder) => string;
12
- export declare const bundle: Bundler;
13
18
  export declare const watch: Watcher;
19
+ export declare const createBundler: (getBuildConfig: (entrypoints: EntryPoints, configBuilder: ConfigBuilder) => WebpackConfig) => Bundler;
20
+ export declare const sandboxBundle: Bundler;
21
+ export declare const nodeBundle: Bundler;
22
+ export declare const nativeUiBundle: InDiskBundler;
14
23
  export {};
15
24
  //# sourceMappingURL=webpack.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../src/webpack.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAkC,OAAO,EAAkB,MAAM,SAAS,CAAC;AAY3F,oBAAY,WAAW,GAAG,KAAK,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,CAAC;AAgDH,UAAU,aAAa;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,gBAAgB,WAAY,aAAa,KAAG,MASxD,CAAC;AAoPF,eAAO,MAAM,MAAM,EAAE,OAqCpB,CAAC;AAgCF,eAAO,MAAM,KAAK,EAAE,OAmCnB,CAAC"}
1
+ {"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../src/webpack.ts"],"names":[],"mappings":"AAGA,OAAgB,EAAY,aAAa,IAAI,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE3F,OAAO,EAAE,OAAO,EAAkC,OAAO,EAAkB,aAAa,EAAE,MAAM,SAAS,CAAC;AAgB1G,oBAAY,WAAW,GAAG,KAAK,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,CAAC;AAQH,eAAO,MAAM,iBAAiB,eAAgB,MAAM,KAAG,MAEtD,CAAC;AAsCF,eAAO,MAAM,gBAAgB,WAAY,aAAa,KAAG,MASxD,CAAC;AACF,aAAK,cAAc,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACrE,aAAK,mBAAmB,GAAG,cAAc,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAClE,aAAK,mBAAmB,GAAG,cAAc,CAAC,aAAa,EAAE,SAAS,GAAG,QAAQ,CAAC,GAAG,MAAM,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;AACvH,eAAO,MAAM,sBAAsB,qCAAsC,aAAa,KAAG,mBA8FxF,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;CACtB;AAwED,eAAO,MAAM,KAAK,EAAE,OAwCnB,CAAC;AAEF,eAAO,MAAM,aAAa,6DACkC,aAAa,KAAK,aAAa,KACxF,OAyCF,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,OAAuD,CAAC;AAEpF,eAAO,MAAM,UAAU,EAAE,OAwBxB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,aAoB5B,CAAC"}
package/out/webpack.js CHANGED
@@ -1,21 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.watch = exports.bundle = exports.getDevToolConfig = void 0;
3
+ exports.nativeUiBundle = exports.nodeBundle = exports.sandboxBundle = exports.createBundler = exports.watch = exports.getCommonWebpackConfig = exports.getDevToolConfig = exports.resolveModulePath = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
6
  const memfs_1 = require("memfs");
7
7
  const path_1 = require("path");
8
8
  const webpack_1 = tslib_1.__importDefault(require("webpack"));
9
- const stub_plugin_1 = require("./stub-plugin");
10
9
  const text_1 = require("./text");
11
10
  const cli_shared_1 = require("@forge/cli-shared");
12
11
  const lint_1 = require("@forge/lint");
12
+ const fs_1 = require("fs");
13
+ const sandboxed_webpack_config_1 = require("./bundler-config/sandboxed-webpack-config");
14
+ const node_webpack_config_1 = require("./bundler-config/node-webpack-config");
13
15
  const tsconfig_interactor_1 = require("./tsconfig-interactor");
16
+ const nativeui_webpack_config_1 = require("./bundler-config/nativeui-webpack-config");
14
17
  const compilerOutputFileSystem = memfs_1.createFsFromVolume(new memfs_1.Volume());
15
18
  const readMemoryFileSync = (filePath) => {
16
19
  return compilerOutputFileSystem.readFileSync(filePath, { encoding: 'utf8' }).toString();
17
20
  };
18
- const resolveModulePath = (moduleName) => {
21
+ exports.resolveModulePath = (moduleName) => {
19
22
  return require.resolve(moduleName);
20
23
  };
21
24
  const handleCallback = (err, stats) => {
@@ -50,43 +53,7 @@ exports.getDevToolConfig = (config) => {
50
53
  }
51
54
  return config.isDebugMode ? 'eval-cheap-module-source-map' : 'cheap-source-map';
52
55
  };
53
- const getCustomModulesAliases = () => {
54
- return {
55
- 'browserify-cipher': resolveModulePath('browserify-cipher/browser.js'),
56
- 'browserify-sign/algos': resolveModulePath('browserify-sign/algos.js'),
57
- 'browserify-sign': resolveModulePath('browserify-sign/browser/index.js'),
58
- 'create-ecdh': resolveModulePath('create-ecdh/browser.js'),
59
- 'create-hash/md5': resolveModulePath('create-hash/md5.js'),
60
- 'create-hash': resolveModulePath('create-hash/browser.js'),
61
- 'create-hmac': resolveModulePath('create-hmac/browser.js'),
62
- 'diffie-hellman': resolveModulePath('diffie-hellman/browser.js'),
63
- pbkdf2: resolveModulePath('pbkdf2/browser.js'),
64
- 'public-encrypt': resolveModulePath('public-encrypt/browser.js'),
65
- randombytes: resolveModulePath('randombytes/browser.js'),
66
- randomfill: resolveModulePath('randomfill/browser.js'),
67
- assert: resolveModulePath('assert/'),
68
- buffer: resolveModulePath('buffer/'),
69
- console: resolveModulePath('console-browserify'),
70
- crypto: resolveModulePath('crypto-browserify'),
71
- events: resolveModulePath('events/'),
72
- os: resolveModulePath('os-browserify/browser'),
73
- punycode: resolveModulePath('punycode/'),
74
- process: resolveModulePath('process/browser.js'),
75
- string_decoder: resolveModulePath('string_decoder/'),
76
- timers: resolveModulePath('timers-browserify'),
77
- url: resolveModulePath('url/'),
78
- util: resolveModulePath('util/'),
79
- zlib: resolveModulePath('browserify-zlib'),
80
- fs: resolveModulePath('memfs'),
81
- http: resolveModulePath('./http'),
82
- https: resolveModulePath('./http'),
83
- path: resolveModulePath('path-browserify'),
84
- querystring: resolveModulePath('querystring-browser'),
85
- stream: resolveModulePath('readable-stream'),
86
- 'supports-color': resolveModulePath('supports-color/index.js')
87
- };
88
- };
89
- const getBuildConfig = (entrypoints, config) => {
56
+ exports.getCommonWebpackConfig = (entrypoints, config) => {
90
57
  if (!require.main) {
91
58
  throw new Error(text_1.Text.noExecutableFile);
92
59
  }
@@ -97,7 +64,6 @@ const getBuildConfig = (entrypoints, config) => {
97
64
  return {
98
65
  entry: Object.assign({}, resolvedEntryPoints),
99
66
  mode: 'production',
100
- target: 'webworker',
101
67
  optimization: {
102
68
  minimize: false
103
69
  },
@@ -108,20 +74,19 @@ const getBuildConfig = (entrypoints, config) => {
108
74
  filename: '[name].js',
109
75
  path: '/'
110
76
  },
77
+ node: {
78
+ __dirname: true
79
+ },
80
+ performance: false,
81
+ resolve: {
82
+ extensions: ['.ts', '.tsx', '.js', '.jsx', '.json']
83
+ },
84
+ resolveLoader: {
85
+ modules: require.resolve.paths('babel-loader') || undefined
86
+ },
87
+ plugins: [new webpack_1.default.IgnorePlugin({ resourceRegExp: /^encoding$/, contextRegExp: /node-fetch/ })],
111
88
  module: {
112
89
  rules: [
113
- {
114
- test: /(readable-stream|pbkdf2|util)\//,
115
- resolve: {
116
- aliasFields: ['browser']
117
- }
118
- },
119
- {
120
- test: /axios\//,
121
- resolve: {
122
- aliasFields: []
123
- }
124
- },
125
90
  {
126
91
  test: /\.jsx?$/,
127
92
  exclude: /node_modules/,
@@ -131,7 +96,7 @@ const getBuildConfig = (entrypoints, config) => {
131
96
  options: {
132
97
  presets: [
133
98
  [
134
- resolveModulePath('@babel/preset-typescript'),
99
+ exports.resolveModulePath('@babel/preset-typescript'),
135
100
  {
136
101
  isTSX: true,
137
102
  jsxPragma: 'ForgeUI',
@@ -141,15 +106,15 @@ const getBuildConfig = (entrypoints, config) => {
141
106
  ],
142
107
  plugins: [
143
108
  [
144
- resolveModulePath('@babel/plugin-transform-react-jsx'),
109
+ exports.resolveModulePath('@babel/plugin-transform-react-jsx'),
145
110
  {
146
111
  pragma: 'ForgeUI.createElement'
147
112
  }
148
113
  ],
149
- resolveModulePath('@forge/babel-plugin-transform-ui'),
150
- resolveModulePath('@babel/plugin-proposal-numeric-separator'),
151
- resolveModulePath('@babel/plugin-proposal-class-properties'),
152
- resolveModulePath('@babel/plugin-proposal-optional-chaining')
114
+ exports.resolveModulePath('@forge/babel-plugin-transform-ui'),
115
+ exports.resolveModulePath('@babel/plugin-proposal-numeric-separator'),
116
+ exports.resolveModulePath('@babel/plugin-proposal-class-properties'),
117
+ exports.resolveModulePath('@babel/plugin-proposal-optional-chaining')
153
118
  ],
154
119
  cacheDirectory: true
155
120
  }
@@ -174,65 +139,14 @@ const getBuildConfig = (entrypoints, config) => {
174
139
  ]
175
140
  }
176
141
  ]
177
- },
178
- node: {
179
- __dirname: true
180
- },
181
- performance: false,
182
- resolve: {
183
- mainFields: ['main', 'module'],
184
- exportsFields: [],
185
- alias: getCustomModulesAliases(),
186
- extensions: ['.ts', '.tsx', '.js', '.jsx', '.json']
187
- },
188
- resolveLoader: {
189
- modules: require.resolve.paths('babel-loader') || undefined
190
- },
191
- plugins: [
192
- new webpack_1.default.IgnorePlugin({ resourceRegExp: /^encoding$/, contextRegExp: /node-fetch/ }),
193
- new webpack_1.default.ProvidePlugin({
194
- Buffer: [resolveModulePath('buffer/'), 'Buffer'],
195
- path: resolveModulePath('path-browserify'),
196
- querystring: resolveModulePath('querystring-browser'),
197
- stream: resolveModulePath('readable-stream'),
198
- TextDecoder: [resolveModulePath('text-encoder-lite'), 'TextDecoderLite'],
199
- TextEncoder: [resolveModulePath('text-encoder-lite'), 'TextEncoderLite'],
200
- URL: [resolveModulePath('whatwg-url'), 'URL'],
201
- URLSearchParams: [resolveModulePath('whatwg-url'), 'URLSearchParams']
202
- }),
203
- new stub_plugin_1.StubPlugin({
204
- modules: [
205
- 'async_hooks',
206
- 'child_process',
207
- 'cluster',
208
- 'constants',
209
- 'dgram',
210
- 'dns',
211
- 'domain',
212
- 'http2',
213
- 'module',
214
- 'net',
215
- 'perf_hooks',
216
- 'readline',
217
- 'repl',
218
- 'sys',
219
- 'tls',
220
- 'trace_events',
221
- 'tty',
222
- 'v8',
223
- 'vm',
224
- 'worker_threads'
225
- ],
226
- placeholder: 'requestedModule',
227
- stub: path_1.resolve(__dirname, 'unsupported')
228
- })
229
- ]
142
+ }
230
143
  };
231
144
  };
232
- const getCompiler = (endpoints, configBuilder) => {
233
- const config = getBuildConfig(endpoints, configBuilder);
234
- const compiler = webpack_1.default(config);
235
- compiler.outputFileSystem = compilerOutputFileSystem;
145
+ const getCompiler = (webpackConfig, options) => {
146
+ const compiler = webpack_1.default(webpackConfig);
147
+ if (!(options === null || options === void 0 ? void 0 : options.writeToDisk)) {
148
+ compiler.outputFileSystem = compilerOutputFileSystem;
149
+ }
236
150
  return compiler;
237
151
  };
238
152
  const getNodeModuleNames = (stats) => {
@@ -262,38 +176,6 @@ class Monitor {
262
176
  this.watcher.close(() => null);
263
177
  }
264
178
  }
265
- exports.bundle = (appDirectory, endpoints) => {
266
- const compiler = getCompiler(endpoints, { isWatchMode: false, appDirectory });
267
- return new Promise((resolve, reject) => {
268
- compiler.run((compilerError, stats) => {
269
- try {
270
- if (!handleCallback(compilerError, stats)) {
271
- return;
272
- }
273
- const output = {}, sourceMap = {};
274
- endpoints.forEach(({ name }) => {
275
- output[name] = readMemoryFileSync(`/${name}.js`).toString();
276
- sourceMap[name] = readMemoryFileSync(`/${name}.js.map`).toString();
277
- });
278
- compiler.close((closeError) => {
279
- if (closeError) {
280
- reject(closeError);
281
- }
282
- });
283
- resolve({
284
- output,
285
- sourceMap,
286
- metadata: {
287
- modules: getNodeModuleNames(stats)
288
- }
289
- });
290
- }
291
- catch (fileReadError) {
292
- reject(fileReadError);
293
- }
294
- });
295
- });
296
- };
297
179
  const runLinter = async (logger = { info: console.log }, fileSystemReader = new cli_shared_1.FileSystemReader(), fileSystemWriter = new cli_shared_1.FileSystemWriter()) => {
298
180
  logger.info(`\n${cli_shared_1.Text.tunnel.preBundleTask(cli_shared_1.Text.lint.running)}`);
299
181
  const filesToLint = await fileSystemReader.recursiveReadDir('./src', [
@@ -318,7 +200,12 @@ const runLinter = async (logger = { info: console.log }, fileSystemReader = new
318
200
  }
319
201
  };
320
202
  exports.watch = (entryPoints, debugMode, callback, watchRun) => {
321
- const compiler = getCompiler(entryPoints, { isWatchMode: true, isDebugMode: debugMode, appDirectory: process.cwd() });
203
+ const config = sandboxed_webpack_config_1.getSandboxedRuntimeBuildConfig(entryPoints, {
204
+ isWatchMode: true,
205
+ isDebugMode: debugMode,
206
+ appDirectory: process.cwd()
207
+ });
208
+ const compiler = getCompiler(config);
322
209
  if (typeof watchRun === 'function') {
323
210
  compiler.hooks.watchRun.tapAsync('watchRun', (watchRunCompiler, watchRunCallback) => {
324
211
  watchRun(watchRunCompiler, runLinter, watchRunCallback);
@@ -347,3 +234,75 @@ exports.watch = (entryPoints, debugMode, callback, watchRun) => {
347
234
  });
348
235
  return new Monitor(watcher);
349
236
  };
237
+ exports.createBundler = (getBuildConfig) => {
238
+ return (appDirectory, endpoints) => {
239
+ const config = getBuildConfig(endpoints, { isWatchMode: false, appDirectory });
240
+ const compiler = getCompiler(config);
241
+ return new Promise((resolve, reject) => {
242
+ compiler.run((compilerError, stats) => {
243
+ try {
244
+ if (!handleCallback(compilerError, stats)) {
245
+ return;
246
+ }
247
+ const output = {}, sourceMap = {};
248
+ endpoints.forEach(({ name }) => {
249
+ output[name] = readMemoryFileSync(`/${name}.js`).toString();
250
+ sourceMap[name] = readMemoryFileSync(`/${name}.js.map`).toString();
251
+ });
252
+ compiler.close((closeError) => {
253
+ if (closeError) {
254
+ reject(closeError);
255
+ }
256
+ });
257
+ resolve({
258
+ output,
259
+ sourceMap,
260
+ metadata: {
261
+ modules: getNodeModuleNames(stats)
262
+ }
263
+ });
264
+ }
265
+ catch (fileReadError) {
266
+ reject(fileReadError);
267
+ }
268
+ });
269
+ });
270
+ };
271
+ };
272
+ exports.sandboxBundle = exports.createBundler(sandboxed_webpack_config_1.getSandboxedRuntimeBuildConfig);
273
+ exports.nodeBundle = async (appDirectory, entryPoints) => {
274
+ const bundler = exports.createBundler(node_webpack_config_1.getNodeRuntimeBuildConfig);
275
+ const { output: bundlerOutput, sourceMap: bundlerSourceMap, metadata } = await bundler(appDirectory, entryPoints);
276
+ const wrapper = fs_1.readFileSync(path_1.join(__dirname, 'wrapper.js')).toString();
277
+ const output = {};
278
+ const sourceMap = {};
279
+ entryPoints.forEach(({ name }) => {
280
+ const wrappedName = 'bundled/' + name;
281
+ output[wrappedName] = bundlerOutput[name];
282
+ const sourceMapValue = bundlerSourceMap === null || bundlerSourceMap === void 0 ? void 0 : bundlerSourceMap[name];
283
+ if (sourceMapValue) {
284
+ sourceMap[wrappedName] = sourceMapValue;
285
+ }
286
+ output[name] = wrapper.replace("'__MODULE__'", JSON.stringify('./' + wrappedName));
287
+ });
288
+ return { output, sourceMap, metadata };
289
+ };
290
+ exports.nativeUiBundle = (appDirectory, entrypoints) => {
291
+ const config = nativeui_webpack_config_1.getNativeUiBuildConfig(entrypoints, { isWatchMode: false, appDirectory });
292
+ const compiler = getCompiler(config, { writeToDisk: true });
293
+ return new Promise((resolve, reject) => {
294
+ compiler.run((compilerError, stats) => {
295
+ try {
296
+ if (!handleCallback(compilerError, stats)) {
297
+ return;
298
+ }
299
+ resolve({
300
+ outputDir: config.output.path
301
+ });
302
+ }
303
+ catch (err) {
304
+ reject(err);
305
+ }
306
+ });
307
+ });
308
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=wrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../src/wrapper.js"],"names":[],"mappings":""}
package/out/wrapper.js ADDED
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ function createInstallationContext({ contextAri }) {
3
+ const ari = {};
4
+ if (ari.resourceType === 'project') {
5
+ return { projectId: ari.resourceId, installContext: contextAri };
6
+ }
7
+ if (ari.resourceType === 'repository') {
8
+ return { repositoryId: ari.resourceId, installContext: contextAri };
9
+ }
10
+ return { installContext: contextAri };
11
+ }
12
+ function isAccountIdDefined(accountId) {
13
+ return accountId !== undefined && accountId !== 'undefined';
14
+ }
15
+ function createPrincipal({ aaid: accountId }) {
16
+ return isAccountIdDefined(accountId) ? { accountId } : undefined;
17
+ }
18
+ function createLicenseContext({ license }) {
19
+ if (license) {
20
+ return {
21
+ license: {
22
+ isActive: license.isActive ? true : false
23
+ }
24
+ };
25
+ }
26
+ }
27
+ function setupRequestContext(meta) {
28
+ return Object.assign(Object.assign({ principal: createPrincipal(meta) }, createLicenseContext(meta)), createInstallationContext(meta));
29
+ }
30
+ const adapter = (fn) => {
31
+ if (typeof fn === 'function') {
32
+ return async (lambdaEvent, _lambdaContext) => {
33
+ const event = lambdaEvent.body;
34
+ const context = setupRequestContext(lambdaEvent._meta);
35
+ const result = await fn(event, context);
36
+ return {
37
+ body: result,
38
+ metrics: []
39
+ };
40
+ };
41
+ }
42
+ else {
43
+ return fn;
44
+ }
45
+ };
46
+ const bundled = require('__MODULE__');
47
+ for (const key in bundled) {
48
+ exports[key] = adapter(bundled[key]);
49
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/bundler",
3
- "version": "3.1.0-test.8",
3
+ "version": "3.1.0",
4
4
  "description": "Default bundler for Forge apps",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Atlassian",
@@ -18,10 +18,10 @@
18
18
  "@babel/plugin-proposal-optional-chaining": "^7.16.7",
19
19
  "@babel/plugin-transform-react-jsx": "^7.16.7",
20
20
  "@babel/preset-typescript": "^7.16.7",
21
- "@forge/api": "2.6.1",
21
+ "@forge/api": "2.7.0",
22
22
  "@forge/babel-plugin-transform-ui": "1.1.0",
23
- "@forge/cli-shared": "2.4.0-next.7",
24
- "@forge/lint": "3.0.4-next.7",
23
+ "@forge/cli-shared": "3.1.0",
24
+ "@forge/lint": "3.2.4",
25
25
  "assert": "^1.1.1",
26
26
  "babel-loader": "^8.2.3",
27
27
  "browserify-zlib": "^0.2.0",
@@ -30,6 +30,7 @@
30
30
  "console-browserify": "^1.1.0",
31
31
  "crypto-browserify": "^3.11.0",
32
32
  "events": "^3.0.0",
33
+ "html-webpack-plugin": "^5.5.0",
33
34
  "memfs": "^3.4.1",
34
35
  "os-browserify": "^0.3.0",
35
36
  "path-browserify": "^1.0.0",
@@ -45,6 +46,7 @@
45
46
  "url": "^0.11.0",
46
47
  "util": "^0.11.0",
47
48
  "webpack": "^5.66.0",
49
+ "webpack-bundle-analyzer": "^4.5.0",
48
50
  "whatwg-url": "^7.0.0"
49
51
  },
50
52
  "devDependencies": {
@@ -53,6 +55,7 @@
53
55
  "@types/react": "^17.0.38",
54
56
  "@types/readable-stream": "^2.3.5",
55
57
  "@types/webpack": "^5.28.0",
58
+ "@types/webpack-bundle-analyzer": "^4.4.1",
56
59
  "@typescript-eslint/eslint-plugin": "^2.10.0",
57
60
  "@typescript-eslint/parser": "^2.10.0",
58
61
  "eslint": "^7.32.0",