chore: switch bundler to tsup
This commit is contained in:
parent
7b6713bc6c
commit
71d6765b05
|
@ -20,7 +20,7 @@ import chalk from 'chalk';
|
||||||
import * as solid from './solid-reactive.js';
|
import * as solid from './solid-reactive.js';
|
||||||
import * as reactively from '@reactively/core';
|
import * as reactively from '@reactively/core';
|
||||||
import Table from 'cli-table';
|
import Table from 'cli-table';
|
||||||
import { reactive, computed } from '../dist/index.js';
|
import { reactive, computed, RNode } from '../dist/index.js';
|
||||||
|
|
||||||
const BATCHED = true;
|
const BATCHED = true;
|
||||||
const RUNS_PER_TIER = 150;
|
const RUNS_PER_TIER = 150;
|
||||||
|
@ -44,10 +44,9 @@ const SOLUTIONS = {
|
||||||
const isSolution = (layers, answer) => answer.every((_, i) => SOLUTIONS[layers][i] === _);
|
const isSolution = (layers, answer) => answer.every((_, i) => SOLUTIONS[layers][i] === _);
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
debugger
|
|
||||||
const report = {};
|
const report = {};
|
||||||
// report.solid = { fn: runSolid, runs: [] };
|
report.solid = { fn: runSolid, runs: [] };
|
||||||
// report.reactively = { fn: runReactively, runs: [], avg: [] };
|
report.reactively = { fn: runReactively, runs: [], avg: [] };
|
||||||
report.inluaReactive = { fn: runInulaReactive, runs: [], avg: [] };
|
report.inluaReactive = { fn: runInulaReactive, runs: [], avg: [] };
|
||||||
// report.inluaDeepReactive = { fn: runInulaDeepReactive, runs: [], avg: [] };
|
// report.inluaDeepReactive = { fn: runInulaDeepReactive, runs: [], avg: [] };
|
||||||
|
|
||||||
|
@ -91,7 +90,6 @@ async function main() {
|
||||||
slowestLib = lib;
|
slowestLib = lib;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
report[fastestLib].runs[i] = chalk.green(report[fastestLib].runs[i].toFixed(2));
|
report[fastestLib].runs[i] = chalk.green(report[fastestLib].runs[i].toFixed(2));
|
||||||
report[slowestLib].runs[i] = chalk.red(report[slowestLib].runs[i].toFixed(2));
|
report[slowestLib].runs[i] = chalk.red(report[slowestLib].runs[i].toFixed(2));
|
||||||
}
|
}
|
||||||
|
@ -113,10 +111,10 @@ async function start(runner, layers) {
|
||||||
|
|
||||||
function runInulaReactive(layers, done) {
|
function runInulaReactive(layers, done) {
|
||||||
const start = {
|
const start = {
|
||||||
a: new reactive(1),
|
a: new RNode(1),
|
||||||
b: new reactive(2),
|
b: new RNode(2),
|
||||||
c: new reactive(3),
|
c: new RNode(3),
|
||||||
d: new reactive(4),
|
d: new RNode(4),
|
||||||
};
|
};
|
||||||
|
|
||||||
let layer = start;
|
let layer = start;
|
||||||
|
@ -124,10 +122,10 @@ function runInulaReactive(layers, done) {
|
||||||
for (let i = layers; i--; ) {
|
for (let i = layers; i--; ) {
|
||||||
layer = (m => {
|
layer = (m => {
|
||||||
return {
|
return {
|
||||||
a: new computed(() => m.b.get()),
|
a: new RNode(() => m.b.get()),
|
||||||
b: new computed(() => m.a.get() - m.c.get()),
|
b: new RNode(() => m.a.get() - m.c.get()),
|
||||||
c: new computed(() => m.b.get() + m.d.get()),
|
c: new RNode(() => m.b.get() + m.d.get()),
|
||||||
d: new computed(() => m.c.get()),
|
d: new RNode(() => m.c.get()),
|
||||||
};
|
};
|
||||||
})(layer);
|
})(layer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rollup --config ./rollup.config.js",
|
"build": "tsup",
|
||||||
"test": "jest --config=jest.config.js",
|
"test": "jest --config=jest.config.js",
|
||||||
"bench": "node --experimental-specifier-resolution=node --inspect ./bench/index.js"
|
"bench": "node --experimental-specifier-resolution=node --inspect ./bench/index.js"
|
||||||
},
|
},
|
||||||
|
@ -16,6 +16,7 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chalk": "^5.3.0",
|
"chalk": "^5.3.0",
|
||||||
"cli-table": "^0.3.11",
|
"cli-table": "^0.3.11",
|
||||||
"tslib": "^2.6.2"
|
"tsup": "^6.7.0",
|
||||||
|
"esbuild-plugin-replace": "^1.4.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,59 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2023 Huawei Technologies Co.,Ltd.
|
|
||||||
*
|
|
||||||
* openInula is licensed under Mulan PSL v2.
|
|
||||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
||||||
* You may obtain a copy of Mulan PSL v2 at:
|
|
||||||
*
|
|
||||||
* http://license.coscl.org.cn/MulanPSL2
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
||||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
||||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
||||||
* See the Mulan PSL v2 for more details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import nodeResolve from '@rollup/plugin-node-resolve';
|
|
||||||
import babel from '@rollup/plugin-babel';
|
|
||||||
import path from 'path';
|
|
||||||
import replace from '@rollup/plugin-replace';
|
|
||||||
|
|
||||||
const extensions = ['.js', '.ts', '.tsx'];
|
|
||||||
|
|
||||||
const getBasicPlugins = mode => {
|
|
||||||
return [
|
|
||||||
nodeResolve({
|
|
||||||
extensions,
|
|
||||||
modulesOnly: true,
|
|
||||||
}),
|
|
||||||
babel({
|
|
||||||
exclude: 'node_modules/**',
|
|
||||||
configFile: path.join(__dirname, './babel.config.cjs'),
|
|
||||||
extensions,
|
|
||||||
}),
|
|
||||||
replace({
|
|
||||||
values: {
|
|
||||||
'process.env.NODE_ENV': `"${mode}"`,
|
|
||||||
},
|
|
||||||
preventAssignment: true,
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
function genConfig(mode) {
|
|
||||||
return {
|
|
||||||
input: path.resolve(__dirname, 'src', 'index.ts'),
|
|
||||||
output: [
|
|
||||||
{
|
|
||||||
file:path.resolve(__dirname, 'dist', 'index.js'),
|
|
||||||
format: 'esm',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
plugins: [
|
|
||||||
...getBasicPlugins(mode),
|
|
||||||
],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export default [genConfig('production')];
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
import {defineConfig} from 'tsup';
|
||||||
|
import {replace} from 'esbuild-plugin-replace';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
esbuildPlugins: [
|
||||||
|
replace({
|
||||||
|
values: {
|
||||||
|
'process.env.NODE_ENV': '\'production\'',
|
||||||
|
},
|
||||||
|
})],
|
||||||
|
entry: [
|
||||||
|
'src/index.ts',
|
||||||
|
],
|
||||||
|
format: [
|
||||||
|
'cjs',
|
||||||
|
'esm',
|
||||||
|
],
|
||||||
|
treeshake: true,
|
||||||
|
clean: true,
|
||||||
|
});
|
|
@ -50,7 +50,7 @@ const getBasicPlugins = mode => {
|
||||||
}),
|
}),
|
||||||
babel({
|
babel({
|
||||||
exclude: 'node_modules/**',
|
exclude: 'node_modules/**',
|
||||||
configFile: path.join(__dirname, '../../babel.config.cjs'),
|
configFile: path.join(__dirname, '../../babel.config.js'),
|
||||||
babelHelpers: 'runtime',
|
babelHelpers: 'runtime',
|
||||||
extensions,
|
extensions,
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Reference in New Issue