@forge/bundler 1.1.1-next.7 → 2.0.0-next.12

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,46 @@
1
1
  # @forge/bundler
2
2
 
3
+ ## 2.0.0-next.12
4
+
5
+ ### Patch Changes
6
+
7
+ - @forge/cli-shared@2.2.1-next.9
8
+ - @forge/lint@3.0.0-next.11
9
+
10
+ ## 2.0.0-next.11
11
+
12
+ ### Patch Changes
13
+
14
+ - 37f9898: Added process dependency to package with notes in the path resolver
15
+
16
+ ## 2.0.0-next.10
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies [f5d4a636]
21
+ - @forge/lint@3.0.0-next.10
22
+ - @forge/cli-shared@2.2.1-next.8
23
+
24
+ ## 2.0.0-next.9
25
+
26
+ ### Major Changes
27
+
28
+ - 037c31a: Upgrade webpack from 4 to 5 and other relavent packages to fix the issue for node17+ (openssl change)
29
+
30
+ ### Patch Changes
31
+
32
+ - Updated dependencies [037c31a]
33
+ - @forge/babel-plugin-transform-ui@1.1.0-next.0
34
+ - @forge/lint@3.0.0-next.9
35
+ - @forge/cli-shared@2.2.1-next.7
36
+
37
+ ## 1.1.1-next.8
38
+
39
+ ### Patch Changes
40
+
41
+ - Updated dependencies [83ca609e]
42
+ - @forge/lint@3.0.0-next.8
43
+
3
44
  ## 1.1.1-next.7
4
45
 
5
46
  ### Patch Changes
@@ -1,10 +1,10 @@
1
- import { Compiler, Plugin } from 'webpack';
1
+ import webpack, { Compiler } from 'webpack';
2
2
  interface StubPluginOptions {
3
3
  modules: string[];
4
4
  placeholder?: string;
5
5
  stub: string;
6
6
  }
7
- export declare class StubPlugin implements Plugin {
7
+ export declare class StubPlugin implements webpack.WebpackPluginInstance {
8
8
  private modules;
9
9
  private placeholder;
10
10
  private stub;
@@ -1 +1 @@
1
- {"version":3,"file":"stub-plugin.d.ts","sourceRoot":"","sources":["../src/stub-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAI3C,UAAU,iBAAiB;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,UAAW,YAAW,MAAM;IACvC,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,WAAW,CAAmC;IACtD,OAAO,CAAC,IAAI,CAA4B;gBAE5B,EAAE,OAAY,EAAE,WAAW,EAAE,IAAS,EAAE,EAAE,iBAAiB;IAMhE,KAAK,CAAC,QAAQ,EAAE,QAAQ;IA2C/B,OAAO,CAAC,cAAc;CAWvB"}
1
+ {"version":3,"file":"stub-plugin.d.ts","sourceRoot":"","sources":["../src/stub-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAI5C,UAAU,iBAAiB;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,UAAW,YAAW,OAAO,CAAC,qBAAqB;IAC9D,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,WAAW,CAAmC;IACtD,OAAO,CAAC,IAAI,CAA4B;gBAE5B,EAAE,OAAY,EAAE,WAAW,EAAE,IAAS,EAAE,EAAE,iBAAiB;IAMhE,KAAK,CAAC,QAAQ,EAAE,QAAQ;IA2C/B,OAAO,CAAC,cAAc;CAWvB"}
@@ -11,7 +11,7 @@ class StubPlugin {
11
11
  apply(compiler) {
12
12
  compiler.resolverFactory.hooks.resolver.for('normal').tap(StubPlugin.name, (resolver) => {
13
13
  resolver.hooks.resolve.tapAsync(StubPlugin.name, (request, resolveContext, callback) => {
14
- const requestedModule = request.__innerRequest;
14
+ const requestedModule = request.request;
15
15
  if (!this.modules.includes(requestedModule)) {
16
16
  return callback();
17
17
  }
package/out/webpack.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { Options } from 'webpack';
2
1
  import { Bundler, Watcher } from './types';
3
2
  export declare type EntryPoints = Array<{
4
3
  name: string;
@@ -9,7 +8,7 @@ interface ConfigBuilder {
9
8
  isDebugMode?: boolean;
10
9
  appDirectory: string;
11
10
  }
12
- export declare const getDevToolConfig: (config: ConfigBuilder) => Options.Devtool;
11
+ export declare const getDevToolConfig: (config: ConfigBuilder) => string;
13
12
  export declare const bundle: Bundler;
14
13
  export declare const watch: Watcher;
15
14
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../src/webpack.ts"],"names":[],"mappings":"AAGA,OAAgB,EAId,OAAO,EAGR,MAAM,SAAS,CAAC;AAGjB,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;AAmDH,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,OAAO,CAAC,OAShE,CAAC;AAiOF,eAAO,MAAM,MAAM,EAAE,OA6BpB,CAAC;AAgCF,eAAO,MAAM,KAAK,EAAE,OAmCnB,CAAC"}
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;AAiPF,eAAO,MAAM,MAAM,EAAE,OAqCpB,CAAC;AAgCF,eAAO,MAAM,KAAK,EAAE,OAmCnB,CAAC"}
package/out/webpack.js CHANGED
@@ -11,16 +11,9 @@ const text_1 = require("./text");
11
11
  const cli_shared_1 = require("@forge/cli-shared");
12
12
  const lint_1 = require("@forge/lint");
13
13
  const tsconfig_interactor_1 = require("./tsconfig-interactor");
14
+ const compilerOutputFileSystem = memfs_1.createFsFromVolume(new memfs_1.Volume());
14
15
  const readMemoryFileSync = (filePath) => {
15
- return memfs_1.fs.readFileSync(filePath, { encoding: 'utf8' });
16
- };
17
- const outputMemoryFileSystem = {
18
- join: path_1.join,
19
- mkdir: memfs_1.fs.mkdir,
20
- mkdirp: memfs_1.fs.mkdirp,
21
- rmdir: memfs_1.fs.rmdir,
22
- unlink: memfs_1.fs.unlink,
23
- writeFile: memfs_1.fs.writeFile
16
+ return compilerOutputFileSystem.readFileSync(filePath, { encoding: 'utf8' }).toString();
24
17
  };
25
18
  const resolveModulePath = (moduleName) => {
26
19
  return require.resolve(moduleName);
@@ -29,9 +22,12 @@ const handleCallback = (err, stats) => {
29
22
  if (err) {
30
23
  throw err;
31
24
  }
25
+ if (!stats) {
26
+ throw new Error('bundle function callback returns empty stats');
27
+ }
32
28
  const info = stats.toJson();
33
- if (stats.hasErrors()) {
34
- const isTSError = info.errors.every((e) => e.includes('[tsl]'));
29
+ if (stats.hasErrors() && info.errors) {
30
+ const isTSError = info.errors.every((e) => e.message.includes('[tsl]'));
35
31
  if (isTSError) {
36
32
  const formattedErrors = info.errors.map((error) => {
37
33
  return error.replace(/\.?.+.tsx?(?!\([0-9]\,[0-9]\))$/gm, '');
@@ -39,14 +35,14 @@ const handleCallback = (err, stats) => {
39
35
  throw new Error(text_1.Text.typescriptError(formattedErrors));
40
36
  }
41
37
  else {
42
- throw new Error(text_1.Text.genericBundlingError(info.errors));
38
+ throw new Error(text_1.Text.genericBundlingError(info.errors.map((e) => e.message)));
43
39
  }
44
40
  }
45
- if (stats.hasWarnings()) {
46
- const warnings = text_1.Text.warnings(info.warnings);
41
+ if (stats.hasWarnings() && info.warnings) {
42
+ const warnings = text_1.Text.warnings(info.warnings.map((e) => e.message));
47
43
  console.warn(chalk_1.default.magenta(warnings));
48
44
  }
49
- return stats;
45
+ return true;
50
46
  };
51
47
  exports.getDevToolConfig = (config) => {
52
48
  if (!config.isWatchMode) {
@@ -65,10 +61,22 @@ const getCustomModulesAliases = () => {
65
61
  'create-hmac': resolveModulePath('create-hmac/browser.js'),
66
62
  'diffie-hellman': resolveModulePath('diffie-hellman/browser.js'),
67
63
  pbkdf2: resolveModulePath('pbkdf2/browser.js'),
68
- process: resolveModulePath('process/browser.js'),
69
64
  'public-encrypt': resolveModulePath('public-encrypt/browser.js'),
70
65
  randombytes: resolveModulePath('randombytes/browser.js'),
71
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'),
72
80
  fs: resolveModulePath('memfs'),
73
81
  http: resolveModulePath('./http'),
74
82
  https: resolveModulePath('./http'),
@@ -168,8 +176,7 @@ const getBuildConfig = (entrypoints, config) => {
168
176
  ]
169
177
  },
170
178
  node: {
171
- __dirname: true,
172
- process: false
179
+ __dirname: true
173
180
  },
174
181
  performance: false,
175
182
  resolve: {
@@ -181,8 +188,9 @@ const getBuildConfig = (entrypoints, config) => {
181
188
  modules: require.resolve.paths('babel-loader') || undefined
182
189
  },
183
190
  plugins: [
184
- new webpack_1.default.IgnorePlugin(/^encoding$/, /node-fetch/),
191
+ new webpack_1.default.IgnorePlugin({ resourceRegExp: /node-fetch/, contextRegExp: /^encoding$/ }),
185
192
  new webpack_1.default.ProvidePlugin({
193
+ Buffer: [resolveModulePath('buffer/'), 'Buffer'],
186
194
  path: resolveModulePath('path-browserify'),
187
195
  querystring: resolveModulePath('querystring-browser'),
188
196
  stream: resolveModulePath('readable-stream'),
@@ -223,14 +231,16 @@ const getBuildConfig = (entrypoints, config) => {
223
231
  const getCompiler = (endpoints, configBuilder) => {
224
232
  const config = getBuildConfig(endpoints, configBuilder);
225
233
  const compiler = webpack_1.default(config);
226
- compiler.outputFileSystem = outputMemoryFileSystem;
234
+ compiler.outputFileSystem = compilerOutputFileSystem;
227
235
  return compiler;
228
236
  };
229
237
  const getNodeModuleNames = (stats) => {
230
238
  const { modules } = stats.toJson({ modules: true });
231
239
  if (modules) {
232
240
  const filteredModuleNames = new Set();
233
- modules.forEach(({ name }) => {
241
+ modules
242
+ .map((m) => m.name || '')
243
+ .forEach((name) => {
234
244
  const parts = name.match(/^\.\/node_modules\/([^/]+)\/([^/]+)/);
235
245
  if (parts) {
236
246
  const module = parts[1][0] === '@' ? `${parts[1]}/${parts[2]}` : parts[1];
@@ -256,11 +266,18 @@ exports.bundle = (appDirectory, endpoints) => {
256
266
  return new Promise((resolve, reject) => {
257
267
  compiler.run((compilerError, stats) => {
258
268
  try {
259
- handleCallback(compilerError, stats);
269
+ if (!handleCallback(compilerError, stats)) {
270
+ return;
271
+ }
260
272
  const output = {}, sourceMap = {};
261
273
  endpoints.forEach(({ name }) => {
262
- output[name] = readMemoryFileSync(`/${name}.js`);
263
- sourceMap[name] = readMemoryFileSync(`/${name}.js.map`);
274
+ output[name] = readMemoryFileSync(`/${name}.js`).toString();
275
+ sourceMap[name] = readMemoryFileSync(`/${name}.js.map`).toString();
276
+ });
277
+ compiler.close((closeError) => {
278
+ if (closeError) {
279
+ reject(closeError);
280
+ }
264
281
  });
265
282
  resolve({
266
283
  output,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/bundler",
3
- "version": "1.1.1-next.7",
3
+ "version": "2.0.0-next.12",
4
4
  "description": "Default bundler for Forge apps",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Atlassian",
@@ -12,42 +12,55 @@
12
12
  "clean": "rm -rf ./out && rm -f tsconfig.tsbuildinfo"
13
13
  },
14
14
  "dependencies": {
15
- "@babel/core": "~7.10.2",
16
- "@babel/plugin-proposal-class-properties": "^7.5.5",
17
- "@babel/plugin-proposal-numeric-separator": "^7.2.0",
18
- "@babel/plugin-proposal-optional-chaining": "^7.12.7",
19
- "@babel/plugin-transform-react-jsx": "^7.3.0",
20
- "@babel/preset-typescript": "^7.6.0",
15
+ "@babel/core": "^7.16.7",
16
+ "@babel/plugin-proposal-class-properties": "^7.16.7",
17
+ "@babel/plugin-proposal-numeric-separator": "^7.16.7",
18
+ "@babel/plugin-proposal-optional-chaining": "^7.16.7",
19
+ "@babel/plugin-transform-react-jsx": "^7.16.7",
20
+ "@babel/preset-typescript": "^7.16.7",
21
21
  "@forge/api": "2.6.0",
22
- "@forge/babel-plugin-transform-ui": "1.0.0",
23
- "@forge/cli-shared": "2.2.1-next.6",
24
- "@forge/lint": "3.0.0-next.7",
25
- "babel-loader": "^8.0.6",
22
+ "@forge/babel-plugin-transform-ui": "1.1.0-next.0",
23
+ "assert": "^2.0.0",
24
+ "babel-loader": "^8.2.3",
25
+ "browserify-zlib": "^0.2.0",
26
+ "buffer": "^6.0.3",
27
+ "@forge/cli-shared": "2.2.1-next.9",
28
+ "@forge/lint": "3.0.0-next.11",
26
29
  "chalk": "^2.4.2",
27
- "memfs": "^2.17.1",
30
+ "console-browserify": "^1.2.0",
31
+ "crypto-browserify": "^3.12.0",
32
+ "events": "^3.3.0",
33
+ "memfs": "^3.4.1",
34
+ "os-browserify": "^0.3.0",
28
35
  "path-browserify": "^1.0.0",
36
+ "process": "^0.11.10",
37
+ "punycode": "^2.1.1",
29
38
  "querystring-browser": "^1.0.4",
30
39
  "readable-stream": "^3.4.0",
40
+ "string_decoder": "^1.3.0",
31
41
  "text-encoder-lite": "^2.0.0",
32
- "ts-loader": "^6.2.2",
42
+ "timers-browserify": "^2.0.12",
43
+ "ts-loader": "^9.2.6",
33
44
  "typescript": "^3.9.7",
34
- "webpack": "^4.42.1",
45
+ "url": "^0.11.0",
46
+ "util": "^0.12.4",
47
+ "webpack": "^5.66.0",
35
48
  "whatwg-url": "^7.0.0"
36
49
  },
37
50
  "devDependencies": {
38
51
  "@types/jest": "^26.0.0",
39
52
  "@types/node": "^12.12.63",
40
- "@types/react": "^16.9.34",
53
+ "@types/react": "^17.0.38",
41
54
  "@types/readable-stream": "^2.3.5",
42
- "@types/webpack": "4.39.8",
55
+ "@types/webpack": "^5.28.0",
43
56
  "@typescript-eslint/eslint-plugin": "^2.10.0",
44
57
  "@typescript-eslint/parser": "^2.10.0",
45
58
  "eslint": "^7.32.0",
46
59
  "eslint-config-prettier": "^6.7.0",
47
60
  "eslint-plugin-prettier": "^3.1.1",
48
- "prettier": "^2.2.1"
61
+ "prettier": "2.2.1"
49
62
  },
50
63
  "engines": {
51
- "node": ">=8.3"
64
+ "node": ">=12.13.1"
52
65
  }
53
66
  }