@forge/bundler 3.0.8 → 3.0.9-next.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @forge/bundler
2
2
 
3
+ ## 3.0.9-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - @forge/cli-shared@2.6.0-next.1
8
+ - @forge/lint@3.1.3-next.1
9
+
10
+ ## 3.0.9-next.1
11
+
12
+ ### Patch Changes
13
+
14
+ - e0f6a1c9: Refactored bundler creation into a factory function
15
+
16
+ ## 3.0.9-next.0
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies [69f42bdc]
21
+ - @forge/cli-shared@2.6.0-next.0
22
+ - @forge/lint@3.1.3-next.0
23
+
3
24
  ## 3.0.8
4
25
 
5
26
  ### Patch Changes
package/out/webpack.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { Configuration as WebpackConfig } from 'webpack';
1
2
  import { Bundler, Watcher } from './types';
2
3
  export declare type EntryPoints = Array<{
3
4
  name: string;
@@ -9,7 +10,8 @@ interface ConfigBuilder {
9
10
  appDirectory: string;
10
11
  }
11
12
  export declare const getDevToolConfig: (config: ConfigBuilder) => string;
12
- export declare const bundle: Bundler;
13
13
  export declare const watch: Watcher;
14
+ export declare const createBundler: (getBuildConfig: (entrypoints: EntryPoints, configBuilder: ConfigBuilder) => WebpackConfig) => Bundler;
15
+ export declare const bundle: Bundler;
14
16
  export {};
15
17
  //# 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,MAAM,SAAS,CAAC;AAG5E,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;AAiRF,eAAO,MAAM,KAAK,EAAE,OAwCnB,CAAC;AAEF,eAAO,MAAM,aAAa,6DACkC,aAAa,KAAK,aAAa,KACxF,OAwCF,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,OAAuD,CAAC"}
package/out/webpack.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.watch = exports.bundle = exports.getDevToolConfig = void 0;
3
+ exports.bundle = exports.createBundler = exports.watch = exports.getDevToolConfig = 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");
@@ -86,7 +86,7 @@ const getCustomModulesAliases = () => {
86
86
  'supports-color': resolveModulePath('supports-color/index.js')
87
87
  };
88
88
  };
89
- const getBuildConfig = (entrypoints, config) => {
89
+ const getSandboxedRuntimeBuildConfig = (entrypoints, config) => {
90
90
  if (!require.main) {
91
91
  throw new Error(text_1.Text.noExecutableFile);
92
92
  }
@@ -229,9 +229,8 @@ const getBuildConfig = (entrypoints, config) => {
229
229
  ]
230
230
  };
231
231
  };
232
- const getCompiler = (endpoints, configBuilder) => {
233
- const config = getBuildConfig(endpoints, configBuilder);
234
- const compiler = webpack_1.default(config);
232
+ const getCompiler = (webpackConfig) => {
233
+ const compiler = webpack_1.default(webpackConfig);
235
234
  compiler.outputFileSystem = compilerOutputFileSystem;
236
235
  return compiler;
237
236
  };
@@ -262,38 +261,6 @@ class Monitor {
262
261
  this.watcher.close(() => null);
263
262
  }
264
263
  }
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
264
  const runLinter = async (logger = { info: console.log }, fileSystemReader = new cli_shared_1.FileSystemReader(), fileSystemWriter = new cli_shared_1.FileSystemWriter()) => {
298
265
  logger.info(`\n${cli_shared_1.Text.tunnel.preBundleTask(cli_shared_1.Text.lint.running)}`);
299
266
  const filesToLint = await fileSystemReader.recursiveReadDir('./src', [
@@ -318,7 +285,12 @@ const runLinter = async (logger = { info: console.log }, fileSystemReader = new
318
285
  }
319
286
  };
320
287
  exports.watch = (entryPoints, debugMode, callback, watchRun) => {
321
- const compiler = getCompiler(entryPoints, { isWatchMode: true, isDebugMode: debugMode, appDirectory: process.cwd() });
288
+ const config = getSandboxedRuntimeBuildConfig(entryPoints, {
289
+ isWatchMode: true,
290
+ isDebugMode: debugMode,
291
+ appDirectory: process.cwd()
292
+ });
293
+ const compiler = getCompiler(config);
322
294
  if (typeof watchRun === 'function') {
323
295
  compiler.hooks.watchRun.tapAsync('watchRun', (watchRunCompiler, watchRunCallback) => {
324
296
  watchRun(watchRunCompiler, runLinter, watchRunCallback);
@@ -347,3 +319,39 @@ exports.watch = (entryPoints, debugMode, callback, watchRun) => {
347
319
  });
348
320
  return new Monitor(watcher);
349
321
  };
322
+ exports.createBundler = (getBuildConfig) => {
323
+ return (appDirectory, endpoints) => {
324
+ const config = getBuildConfig(endpoints, { isWatchMode: false, appDirectory });
325
+ const compiler = getCompiler(config);
326
+ return new Promise((resolve, reject) => {
327
+ compiler.run((compilerError, stats) => {
328
+ try {
329
+ if (!handleCallback(compilerError, stats)) {
330
+ return;
331
+ }
332
+ const output = {}, sourceMap = {};
333
+ endpoints.forEach(({ name }) => {
334
+ output[name] = readMemoryFileSync(`/${name}.js`).toString();
335
+ sourceMap[name] = readMemoryFileSync(`/${name}.js.map`).toString();
336
+ });
337
+ compiler.close((closeError) => {
338
+ if (closeError) {
339
+ reject(closeError);
340
+ }
341
+ });
342
+ resolve({
343
+ output,
344
+ sourceMap,
345
+ metadata: {
346
+ modules: getNodeModuleNames(stats)
347
+ }
348
+ });
349
+ }
350
+ catch (fileReadError) {
351
+ reject(fileReadError);
352
+ }
353
+ });
354
+ });
355
+ };
356
+ };
357
+ exports.bundle = exports.createBundler(getSandboxedRuntimeBuildConfig);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/bundler",
3
- "version": "3.0.8",
3
+ "version": "3.0.9-next.2",
4
4
  "description": "Default bundler for Forge apps",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Atlassian",
@@ -20,8 +20,8 @@
20
20
  "@babel/preset-typescript": "^7.16.7",
21
21
  "@forge/api": "2.7.0",
22
22
  "@forge/babel-plugin-transform-ui": "1.1.0",
23
- "@forge/cli-shared": "2.5.1",
24
- "@forge/lint": "3.1.2",
23
+ "@forge/cli-shared": "2.6.0-next.1",
24
+ "@forge/lint": "3.1.3-next.1",
25
25
  "assert": "^1.1.1",
26
26
  "babel-loader": "^8.2.3",
27
27
  "browserify-zlib": "^0.2.0",