@rock-js/plugin-repack 0.8.13

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 ADDED
@@ -0,0 +1,7 @@
1
+ # @rock-js/plugin-repack
2
+
3
+ Re.Pack integration plugin for Rock (Rock). This package is part of the Rock ecosystem and provides integration with [Re.Pack](https://re-pack.dev), a toolkit for building React Native apps with webpack or Rspack.
4
+
5
+ ## Documentation
6
+
7
+ For detailed documentation about Rock and its tools, visit [Rock Documentation](https://rockjs.dev)
@@ -0,0 +1 @@
1
+ export * from './lib/pluginRepack.js';
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './lib/pluginRepack.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { PluginApi, PluginOutput } from '@rock-js/config';
2
+ type PluginConfig = {
3
+ platforms?: {
4
+ [key: string]: object;
5
+ };
6
+ };
7
+ export declare const pluginRepack: (pluginConfig?: PluginConfig) => (api: PluginApi) => PluginOutput;
8
+ export default pluginRepack;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pluginRepack.d.ts","sourceRoot":"","sources":["../../../src/lib/pluginRepack.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAW5D,KAAK,YAAY,GAAG;IAClB,SAAS,CAAC,EAAE;QACV,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;CACH,CAAC;AAWF,eAAO,MAAM,YAAY,kBACR,YAAY,WACrB,SAAS,KAAG,YA4FjB,CAAC;AAEJ,eAAe,YAAY,CAAC"}
@@ -0,0 +1,72 @@
1
+ import commands from '@callstack/repack/commands/rspack';
2
+ import { colorLink, findDevServerPort, intro, logger, RockError, runHermes, spinner, } from '@rock-js/tools';
3
+ const startCommand = commands.find((command) => command.name === 'start');
4
+ const bundleCommand = commands.find((command) => command.name === 'bundle');
5
+ export const pluginRepack = (pluginConfig = {}) => (api) => {
6
+ if (!startCommand) {
7
+ throw new RockError('Re.Pack "start" command not found.');
8
+ }
9
+ if (!bundleCommand) {
10
+ throw new RockError('Re.Pack "bundle" command not found.');
11
+ }
12
+ api.registerCommand({
13
+ name: 'start',
14
+ description: 'Starts Re.Pack dev server.',
15
+ action: async (args) => {
16
+ const root = api.getProjectRoot();
17
+ const platforms = api.getPlatforms();
18
+ const { port, startDevServer } = await findDevServerPort(args.port ? Number(args.port) : 8081, root);
19
+ if (!startDevServer) {
20
+ return;
21
+ }
22
+ startCommand.func([],
23
+ // @ts-expect-error TODO fix getPlatforms type
24
+ { root, platforms, ...pluginConfig }, { ...args, port });
25
+ },
26
+ // @ts-expect-error fixup types
27
+ options: startCommand.options,
28
+ });
29
+ api.registerCommand({
30
+ name: 'bundle',
31
+ description: 'Bundles JavaScript with Re.Pack.',
32
+ action: async (args) => {
33
+ if (!args.entryFile) {
34
+ throw new RockError('"rock bundle" command is missing "--entry-file" argument.');
35
+ }
36
+ intro('Compiling JS bundle with Re.Pack');
37
+ const root = api.getProjectRoot();
38
+ const platforms = api.getPlatforms();
39
+ await bundleCommand.func([],
40
+ // @ts-expect-error TODO fix getPlatforms type
41
+ { root, platforms, ...pluginConfig }, args);
42
+ if (args.hermes) {
43
+ if (!args.bundleOutput) {
44
+ throw new RockError('Missing "--bundle-output" argument to run "bundle --hermes".');
45
+ }
46
+ const loader = spinner();
47
+ loader.start('Running Hermes compiler...');
48
+ await runHermes({
49
+ bundleOutputPath: args.bundleOutput,
50
+ sourcemapOutputPath: args.sourcemapOutput,
51
+ });
52
+ loader.stop(`Hermes bytecode bundle created at: ${colorLink(args.bundleOutput)}`);
53
+ }
54
+ else if (args.bundleOutput) {
55
+ logger.info(`JavaScript bundle created at: ${colorLink(args.bundleOutput)}`);
56
+ }
57
+ },
58
+ options: [
59
+ ...bundleCommand.options,
60
+ {
61
+ name: '--hermes',
62
+ description: 'Passes the output JS bundle to Hermes compiler and outputs a bytecode file.',
63
+ },
64
+ ],
65
+ });
66
+ return {
67
+ name: '@rock-js/plugin-repack',
68
+ description: 'Rock plugin for Re.Pack toolkit with Rspack.',
69
+ };
70
+ };
71
+ export default pluginRepack;
72
+ //# sourceMappingURL=pluginRepack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pluginRepack.js","sourceRoot":"","sources":["../../../src/lib/pluginRepack.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,mCAAmC,CAAC;AAEzD,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,KAAK,EACL,MAAM,EACN,SAAS,EACT,SAAS,EACT,OAAO,GACR,MAAM,gBAAgB,CAAC;AAcxB,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC;AAC1E,MAAM,aAAa,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;AAE5E,MAAM,CAAC,MAAM,YAAY,GACvB,CAAC,eAA6B,EAAE,EAAE,EAAE,CACpC,CAAC,GAAc,EAAgB,EAAE;IAC/B,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,SAAS,CAAC,oCAAoC,CAAC,CAAC;IAC5D,CAAC;IAED,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,SAAS,CAAC,qCAAqC,CAAC,CAAC;IAC7D,CAAC;IAED,GAAG,CAAC,eAAe,CAAC;QAClB,IAAI,EAAE,OAAO;QACb,WAAW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IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;oBACvB,MAAM,IAAI,SAAS,CACjB,8DAA8D,CAC/D,CAAC;gBACJ,CAAC;gBAED,MAAM,MAAM,GAAG,OAAO,EAAE,CAAC;gBACzB,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;gBAC3C,MAAM,SAAS,CAAC;oBACd,gBAAgB,EAAE,IAAI,CAAC,YAAY;oBACnC,mBAAmB,EAAE,IAAI,CAAC,eAAe;iBAC1C,CAAC,CAAC;gBACH,MAAM,CAAC,IAAI,CACT,sCAAsC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CACrE,CAAC;YACJ,CAAC;iBAAM,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBAC7B,MAAM,CAAC,IAAI,CACT,iCAAiC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAChE,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO,EAAE;YACP,GAAG,aAAa,CAAC,OAAO;YACxB;gBACE,IAAI,EAAE,UAAU;gBAChB,WAAW,EACT,6EAA6E;aAChF;SACF;KACF,CAAC,CAAC;IAEH,OAAO;QACL,IAAI,EAAE,wBAAwB;QAC9B,WAAW,EAAE,8CAA8C;KAC5D,CAAC;AACJ,CAAC,CAAC;AAEJ,eAAe,YAAY,CAAC"}
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@rock-js/plugin-repack",
3
+ "version": "0.8.13",
4
+ "type": "module",
5
+ "types": "./dist/src/index.d.ts",
6
+ "exports": {
7
+ "types": "./dist/src/index.d.ts",
8
+ "default": "./dist/src/index.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "template"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsc -p tsconfig.lib.json",
16
+ "dev": "tsc -p tsconfig.lib.json --watch",
17
+ "publish:npm": "npm publish --access public",
18
+ "publish:verdaccio": "npm publish --registry http://localhost:4873 --userconfig ../../.npmrc"
19
+ },
20
+ "dependencies": {
21
+ "@rock-js/tools": "^0.8.13",
22
+ "tslib": "^2.3.0"
23
+ },
24
+ "devDependencies": {
25
+ "@rock-js/config": "^0.8.13"
26
+ },
27
+ "peerDependencies": {
28
+ "@callstack/repack": "^5.0.3",
29
+ "@rspack/core": "^1.2.8",
30
+ "@swc/helpers": "^0.5.15"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ }
35
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "rock-plugin-repack-template",
3
+ "devDependencies": {
4
+ "@rock-js/plugin-repack": "^0.8.13",
5
+ "@callstack/repack": "^5.0.3",
6
+ "@rspack/core": "^1.2.8",
7
+ "@swc/helpers": "^0.5.15"
8
+ }
9
+ }
@@ -0,0 +1,28 @@
1
+ import path from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ import * as Repack from '@callstack/repack';
4
+
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
7
+
8
+ /**
9
+ * Rspack configuration enhanced with Re.Pack defaults for React Native.
10
+ *
11
+ * Learn about Rspack configuration: https://rspack.dev/config/
12
+ * Learn about Re.Pack configuration: https://re-pack.dev/docs/guides/configuration
13
+ */
14
+
15
+ export default {
16
+ context: __dirname,
17
+ entry: './index.js',
18
+ resolve: {
19
+ ...Repack.getResolveOptions(),
20
+ },
21
+ module: {
22
+ rules: [
23
+ ...Repack.getJsTransformRules(),
24
+ ...Repack.getAssetTransformRules(),
25
+ ],
26
+ },
27
+ plugins: [new Repack.RepackPlugin()],
28
+ };