Skip to content
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nullstack",
"version": "0.16.1",
"version": "0.16.2",
"description": "Full-stack Javascript Components for one-dev armies",
"main": "nullstack.js",
"author": "Mortaro",
Expand Down
5 changes: 5 additions & 0 deletions types/ClientContext.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import { NullstackWorker } from './Worker';
* @see https://nullstack.app/context
*/
export type NullstackClientContext<TProps = unknown> = TProps & {
/**
* Callback function that bootstrap the context for the application.
*/
start?: () => void;

/**
* Information about the document `head` metatags.
*
Expand Down
5 changes: 5 additions & 0 deletions types/ServerContext.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import { NullstackWorker } from './Worker';
* @see https://nullstack.app/context
*/
export type NullstackServerContext<TProps = unknown> = TProps & {
/**
* Callback function that bootstrap the context for the application.
*/
start?: () => void;

/**
* Information about the app manifest and some metatags.
*
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class Nullstack<TProps = unknown> {
/**
* @param App A Nullstack app root component
*/
static start(App: Nullstack): NullstackClientContext | NullstackServerContext;
static start(App: typeof this): NullstackClientContext | NullstackServerContext;

/**
* Use a plugin
Expand Down
34 changes: 28 additions & 6 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require('path');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const TerserPlugin = require('terser-webpack-plugin');
const crypto = require("crypto");
const { readdirSync } = require('fs');
const { existsSync, readdirSync } = require('fs');
const NodemonPlugin = require('nodemon-webpack-plugin');
const CopyPlugin = require("copy-webpack-plugin");

Expand Down Expand Up @@ -38,7 +38,7 @@ function terserMinimizer(file, _sourceMap) {
})
}

const swc = {
const swcJs = {
test: /\.js$/,
use: {
loader: require.resolve('swc-loader'),
Expand All @@ -56,6 +56,24 @@ const swc = {
}
};

const swcTs = {
test: /\.ts$/,
use: {
loader: require.resolve('swc-loader'),
options: {
jsc: {
parser: {
syntax: "typescript",
exportDefaultFrom: true,
},
},
env: {
targets: { node: "10" }
}
}
}
};

const nullstackJavascript = {
test: /\.(njs|nts|jsx|tsx)$/,
use: {
Expand Down Expand Up @@ -110,6 +128,7 @@ const nullstackTypescript = {

function server(env, argv) {
const dir = argv.input ? path.join(__dirname, argv.input) : process.cwd();
const entryExtension = existsSync(path.join(dir, 'server.ts')) ? 'ts' : 'js';
const icons = {};
const publicFiles = readdirSync(path.join(dir, 'public'));
for (const file of publicFiles) {
Expand Down Expand Up @@ -137,7 +156,7 @@ function server(env, argv) {
infrastructureLogging: {
console: customConsole,
},
entry: './server.js',
entry: './server.' + entryExtension,
output: {
path: path.join(dir, folder),
filename: 'server.js',
Expand Down Expand Up @@ -197,7 +216,8 @@ function server(env, argv) {
]
}
},
swc,
swcJs,
swcTs,
nullstackJavascript,
{
test: /\.(njs|nts|jsx|tsx)$/,
Expand Down Expand Up @@ -246,6 +266,7 @@ function server(env, argv) {
function client(env, argv) {
const disk = !!argv.disk
const dir = argv.input ? path.join(__dirname, argv.input) : process.cwd();
const entryExtension = existsSync(path.join(dir, 'client.ts')) ? 'ts' : 'js';
const isDev = argv.environment === 'development';
const folder = isDev ? '.development' : '.production';
const devtool = isDev ? 'inline-cheap-module-source-map' : false;
Expand All @@ -268,7 +289,7 @@ function client(env, argv) {
console: customConsole,
},
mode: argv.environment,
entry: './client.js',
entry: './client.' + entryExtension,
output: {
publicPath: `/`,
path: path.join(dir, folder),
Expand Down Expand Up @@ -306,7 +327,8 @@ function client(env, argv) {
]
}
},
swc,
swcJs,
swcTs,
nullstackJavascript,
{
test: /\.(njs|nts|jsx|tsx)$/,
Expand Down