Skip to content

Commit

Permalink
change build to rollup
Browse files Browse the repository at this point in the history
add modules exports
  • Loading branch information
s00d committed Oct 18, 2023
1 parent e9516c9 commit 2804bbc
Show file tree
Hide file tree
Showing 6 changed files with 2,132 additions and 1,019 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ dist
temp
browser
coverage
.DS_store
.DS_store
package-lock.json
.yarnrc.yml
.yarn
32 changes: 22 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@
"name": "allof-merge",
"version": "0.5.1",
"description": "Simplify your JsonSchema by combining allOf safely.",
"module": "dist/esm/index.js",
"main": "dist/cjs/index.js",
"types": "dist/cjs/index.d.ts",
"module": "dist/index.mjs",
"main": "dist/index.cjs",
"browser": "./dist/index.iife.js",
"typings": "dist/index.d.ts",
"files": [
"dist",
"browser"
],
"browser": {
"./dist/cjs/index.js": "./browser/allof-merge.js"
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"scripts": {
"build": "tsc && tsc --module commonjs --outDir dist/cjs",
"prebuild": "rimraf ./dist",
"build": "rollup -c",
"test": "jest --verbose",
"prepublish": "rm -r dist || true && yarn build && yarn build:web",
"test:coverage": "jest --verbose --coverage",
"build:web": "vite build",
"benchmark": "yarn build && node benchmark"
},
"keywords": [
Expand All @@ -39,19 +43,27 @@
"author": "Damir Yusipov",
"license": "MIT",
"devDependencies": {
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.0.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.5",
"@types/jest": "^29.5.2",
"@types/js-yaml": "^4.0.5",
"benchmark": "^2.1.4",
"jest": "^29.5.0",
"js-yaml": "^4.1.0",
"json-schema-merge-allof": "^0.8.1",
"rimraf": "^5.0.5",
"rollup": "^2.79.1",
"rollup-plugin-filesize": "^10.0.0",
"rollup-plugin-progress": "^1.1.2",
"ts-jest": "^29.1.0",
"ts-loader": "^9.4.3",
"ts-node": "^10.7.0",
"tslint": "^6.1.2",
"typescript": "^5.1.3",
"vite": "^4.3.9",
"vite-plugin-dts": "^2.0.2"
"typescript": "^5.1.3"
},
"jest": {
"transform": {
Expand Down
78 changes: 78 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import babel from '@rollup/plugin-babel';
import filesize from 'rollup-plugin-filesize';
import progress from 'rollup-plugin-progress';
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json';
import resolve from '@rollup/plugin-node-resolve';
import pkg from './package.json';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';

const inputPath = './src'

const banner = `/*!
* allof-merge v${pkg.version}
*
* Copyright (C) 2012-${new Date().getFullYear()} ${pkg.author}.
*
* Date: ${new Date().toUTCString()}
*/
`;

const extensions = ['.ts', '.js'];

const jsPlugins = [
resolve(),
commonjs({
include: 'node_modules/**',
}),
json(),
progress(),
filesize({
showGzippedSize: true,
}),
typescript(),
babel({
babelHelpers: 'bundled',
exclude: 'node_modules/**',
include: [`${inputPath}/**/*`],
extensions,
}),
terser()
];

export default [
{
input: `${inputPath}/index.ts`,
output: {
file: `${pkg.main}`,
format: 'umd',
banner,
name: 'AllofMerge',
sourcemap: true,
},
plugins: jsPlugins
},
{
input: `${inputPath}/index.ts`,
output: {
file: `${pkg.module}`,
banner,
format: 'esm',
name: 'AllofMerge',
sourcemap: true,
},
plugins: jsPlugins
},
{
input: `${inputPath}/index.ts`,
output: {
file: `${pkg.browser}`,
banner,
format: 'iife',
name: 'AllofMerge',
sourcemap: true,
},
plugins: jsPlugins
},
];
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"module": "esnext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": ["es2019"], /* Specify library files to be included in the compilation. */
"allowJs": false, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
Expand All @@ -14,7 +14,7 @@
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "dist/esm", /* Redirect output structure to the directory. */
"outDir": "dist", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
Expand Down
21 changes: 0 additions & 21 deletions vite.config.js

This file was deleted.

Loading

0 comments on commit 2804bbc

Please sign in to comment.