Skip to content

Commit

Permalink
build: generation of umd and esm
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabiopf02 committed Aug 7, 2023
1 parent 81b9b91 commit cb961f2
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 66 deletions.
50 changes: 25 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 4 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ofx-data-extractor",
"version": "1.2.2",
"version": "1.2.1",
"keywords": [
"ofx",
"financial",
Expand Down Expand Up @@ -34,20 +34,13 @@
"url": "https://github.com/Fabiopf02/ofx-ts/issues"
},
"license": "MIT",
"description": "",
"main": "dist/index.js",
"module": "dist/index.mjs",
"description": "A module written in TypeScript that provides a utility to extract data from an OFX file in Node.js and Browser",
"main": "dist/umd/bundle.min.js",
"module": "dist/esm/index.min.js",
"typings": "dist/index.d.ts",
"files": [
"dist/**/*"
],
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.esm.js"
}
},
"scripts": {
"test": "jest tests/*.spec.ts --config jest.config.js",
"test:coverage": "jest tests/*.spec.ts --coverage --config jest.config.js",
Expand Down
71 changes: 42 additions & 29 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,50 @@ const { minify } = require('rollup-plugin-esbuild')
const typescript = require('@rollup/plugin-typescript')
const commonjs = require('@rollup/plugin-commonjs')
const nodeResolve = require('@rollup/plugin-node-resolve')
const name = require('./package.json').main.replace(/\.js$/, '')
const lib = require('./package.json')

/**
* @type {import('rollup').RollupOptions}
*/
module.exports = [
{
input: 'src/index.ts',
treeshake: true,
plugins: [
typescript({ tsconfig: './tsconfig.json' }),
commonjs(),
nodeResolve(),
minify({
keepNames: false,
treeShaking: true,
minify: true,
}),
],
output: [
{
file: `${name}.js`,
format: 'cjs',
sourcemap: false,
},
{
file: `${name}.js`,
format: 'iife',
name: 'ofx',
sourcemap: false,
module.exports = () => {
const year = new Date().getFullYear()
const banner = `// Ofx-data-extractor v${lib.version} Copyright (c) ${year} ${lib.author}`

return [
{
input: 'src/index.ts',
treeshake: true,
plugins: [
typescript({ declaration: false }),
commonjs(),
nodeResolve(),
minify({
keepNames: false,
treeShaking: true,
minify: true,
banner,
globalName: 'ofx',
}),
],
output: [
{
file: 'dist/umd/bundle.min.js',
format: 'umd',
name: 'ofx',
},
{
file: 'dist/esm/index.min.js',
format: 'esm',
},
],
},
{
input: 'src/index.ts',
plugins: [typescript({ tsconfig: './tsconfig.json' })],
output: {
file: 'dist/index.d.ts',
format: 'esm',
},
],
},
]
},
]
}
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"outDir": "dist",
"baseUrl": ".",
"esModuleInterop": true,
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
"declaration": true,
"strict": true,
Expand Down

0 comments on commit cb961f2

Please sign in to comment.