@forge/bundler 3.0.12-next.2 → 3.1.0-next.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,5 +1,36 @@
1
1
  # @forge/bundler
2
2
 
3
+ ## 3.1.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 89ae99e0: Add support for auto-bundling resources
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [89ae99e0]
12
+ - @forge/cli-shared@3.1.0-next.0
13
+ - @forge/lint@3.2.4-next.0
14
+
15
+ ## 3.0.12
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [5424f97]
20
+ - Updated dependencies [35172f2]
21
+ - Updated dependencies [edab85a]
22
+ - Updated dependencies [5972825c]
23
+ - @forge/cli-shared@3.0.0
24
+ - @forge/lint@3.2.3
25
+
26
+ ## 3.0.12-next.3
27
+
28
+ ### Patch Changes
29
+
30
+ - Updated dependencies [5424f97]
31
+ - @forge/cli-shared@3.0.0-next.3
32
+ - @forge/lint@3.2.3-next.3
33
+
3
34
  ## 3.0.12-next.2
4
35
 
5
36
  ### Patch Changes
@@ -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
+ };
package/out/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { Bundler, Watcher, WatcherMonitor, BundlerOutput } from './types';
2
- export { sandboxBundle, nodeBundle, 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,aAAa,EAAE,UAAU,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
@@ -3,4 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var webpack_1 = require("./webpack");
4
4
  Object.defineProperty(exports, "sandboxBundle", { enumerable: true, get: function () { return webpack_1.sandboxBundle; } });
5
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; } });
6
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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,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,5 +1,5 @@
1
1
  import { Configuration as WebpackConfig, ModuleOptions } from 'webpack';
2
- import { Bundler, Watcher } from './types';
2
+ import { Bundler, Watcher, InDiskBundler } from './types';
3
3
  export declare type EntryPoints = Array<{
4
4
  name: string;
5
5
  path: string;
@@ -19,5 +19,6 @@ export declare const watch: Watcher;
19
19
  export declare const createBundler: (getBuildConfig: (entrypoints: EntryPoints, configBuilder: ConfigBuilder) => WebpackConfig) => Bundler;
20
20
  export declare const sandboxBundle: Bundler;
21
21
  export declare const nodeBundle: Bundler;
22
+ export declare const nativeUiBundle: InDiskBundler;
22
23
  export {};
23
24
  //# sourceMappingURL=webpack.d.ts.map
@@ -1 +1 @@
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,MAAM,SAAS,CAAC;AAe3F,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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,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,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.nodeBundle = exports.sandboxBundle = exports.createBundler = exports.watch = exports.getCommonWebpackConfig = exports.getDevToolConfig = exports.resolveModulePath = 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");
@@ -13,6 +13,7 @@ const fs_1 = require("fs");
13
13
  const sandboxed_webpack_config_1 = require("./bundler-config/sandboxed-webpack-config");
14
14
  const node_webpack_config_1 = require("./bundler-config/node-webpack-config");
15
15
  const tsconfig_interactor_1 = require("./tsconfig-interactor");
16
+ const nativeui_webpack_config_1 = require("./bundler-config/nativeui-webpack-config");
16
17
  const compilerOutputFileSystem = memfs_1.createFsFromVolume(new memfs_1.Volume());
17
18
  const readMemoryFileSync = (filePath) => {
18
19
  return compilerOutputFileSystem.readFileSync(filePath, { encoding: 'utf8' }).toString();
@@ -141,9 +142,11 @@ exports.getCommonWebpackConfig = (entrypoints, config) => {
141
142
  }
142
143
  };
143
144
  };
144
- const getCompiler = (webpackConfig) => {
145
+ const getCompiler = (webpackConfig, options) => {
145
146
  const compiler = webpack_1.default(webpackConfig);
146
- compiler.outputFileSystem = compilerOutputFileSystem;
147
+ if (!(options === null || options === void 0 ? void 0 : options.writeToDisk)) {
148
+ compiler.outputFileSystem = compilerOutputFileSystem;
149
+ }
147
150
  return compiler;
148
151
  };
149
152
  const getNodeModuleNames = (stats) => {
@@ -284,3 +287,22 @@ exports.nodeBundle = async (appDirectory, entryPoints) => {
284
287
  });
285
288
  return { output, sourceMap, metadata };
286
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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/bundler",
3
- "version": "3.0.12-next.2",
3
+ "version": "3.1.0-next.0",
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": "3.0.0-next.2",
24
- "@forge/lint": "3.2.3-next.2",
23
+ "@forge/cli-shared": "3.1.0-next.0",
24
+ "@forge/lint": "3.2.4-next.0",
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",