Skip to content

About

The application builder for bare-refresh

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

bare-refresh-build

Build an application that boots a https://github.com/holepunchto/bare-refresh host instead of running itself. The application is packed into a bundle and staged next to a generated entry, which starts a host for the bundle and connects it to a server. The staged package is then built into an app with https://github.com/holepunchto/bare-build.

npm i bare-refresh-build

Usage

const build = require('bare-refresh-build')

const { bundle } = await build.pack({ entry: 'app.js', host: 'darwin-arm64' })

await build(bundle, {
  base: __dirname,
  entry: 'app.js',
  host: 'darwin-arm64',
  name: 'Demo',
  identifier: 'to.holepunch.demo',
  runtime: 'bare-native/runtime',
  client: 'bare-refresh-transport-tcp/connect',
  options: { port: 9000 }
})

The host is booted with the https://github.com/holepunchto/bare-refresh this module depends on. The generated entry requires client and the modules to attach as they are given: a specifier is resolved from base, so the application has to be able to resolve it, while an absolute path is required from where it is. A tool that provides them on behalf of the application can therefore pass paths of its own. An entry of attach can also carry options, which are passed to the attached function after the host:

await build(bundle, {
  // ...
  client: require.resolve('tool/connect'),
  attach: [
    require.resolve('tool/overlay'),
    [require.resolve('tool/devtools'), { host: '192.168.1.2' }]
  ],
  build: { ios: { provisioningProfile: 'App.mobileprovision' } }
})

Modules that must run before the application, inside the graph of the host rather than beside it, are passed to pack() as preload. They are packed with the application and share its modules, such as a refresh runtime that has to see the same React. Pass the same preload when building, so that the addons they reach are linked:

const { bundle } = await build.pack({
  entry: 'app.js',
  preload: [require.resolve('tool/refresh')],
  host: 'darwin-arm64'
})

Options for https://github.com/holepunchto/bare-build that are not set otherwise, such as signing options, are passed in build.

License

Apache-2.0

About

The application builder for bare-refresh

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages