1.0.16 • Published 5 years ago

@tessin/tcm-boot v1.0.16

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

TCM boot loader

Bootstrapping code for client (browser) and server (Node.js). The purpose of this code is to allow us to track code dependencies as they are loaded into the process as well as allow us to create isolated runtime environments that can be used to evict.

API

ModuleFunctionArguments
lib/clientclientBootLoader{ index, cache, initialProps, main, externals }
lib/serverserverBootLoader{ index, cache, initialProps, main }
lib/instantiateinstantiateBootLoader{ index, cache, initialProps, main }

Example

The entry point must export a function, like this:

import { EntryPoint } from "@tessin/tcm-boot"

const main: EntryPoint = function(index, cache, initialProps, useRequireHook) {
  // <your code goes here>
}

export = main

This function doesn't have to do anything in particular. It can access the bundle dependencies from the index, cache and initialProps respectively. For more advanced situations you can use useRequireHook to install a custom function that will be used to require module from then on.

ArgumentDescription
indexModule ID to source text (JavaScript)
cacheModule ID to module instance (loaded)
initialPropsAny properties passed along with the creation of the bootloader
useRequireHookUsed to install a require hook

The cache is only used to pass data dependencies to the boot loader. However, initialized modules from the bootstrapping process will be loaded into cache before main is called.

Client/browser

Code will run as part of the DOMContentLoaded event.

The client boot loader is sanitized to minimize attack surfaces.

Server/Node.js

Code will run as required propagating the return value from the main entry point function as exports.

There are two variants of the server boot loader, serverBootLoader which will return a JavaScript string and instantiateBootLoader which will bootstrap a new CommonJS environment in the current running process.

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago