Skip to content

Commit

Permalink
Merge pull request #16 from belgattitude/sourcemap
Browse files Browse the repository at this point in the history
chore: add sourcemaps
  • Loading branch information
belgattitude authored Sep 11, 2022
2 parents 1a07f76 + bac3dca commit 1e98a56
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .changeset/warm-dodos-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@belgattitude/http-exception': patch
---

Add sourcemaps to published dist
2 changes: 1 addition & 1 deletion packages/http-exception/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"CHANGELOG.md"
],
"scripts": {
"build": "rimraf --no-glob ./dist && rollup -c rollup.config.js",
"build": "rimraf --no-glob ./dist && cross-env NODE_ENV=production rollup -c rollup.config.js",
"clean": "rimraf --no-glob ./dist ./coverage ./tsconfig.tsbuildinfo",
"build-doc": "rimraf --no-glob ./docs/api && typedoc --plugin typedoc-plugin-markdown",
"prettier-check": "yarn run --top-level prettier --check --config ../../.prettierrc.js --ignore-path ../../.prettierignore \"./**/*.{js,jsx,cjs,mjs,ts,tsx,mts,md,mdx,json,css,scss,less}\"",
Expand Down
36 changes: 18 additions & 18 deletions packages/http-exception/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ const require = createRequire(import.meta.url);

const pkg = require('./package.json');

const external = [
...Object.keys(pkg.dependencies ?? {}),
...Object.keys(pkg?.peerDependencies ?? {}),
];

const distDir = './dist';

const ecmascriptLevel = 'es2017';
const config = {
distDir: './dist',
ecmascriptLevel: 'es2017',
sourceMap: process.env.NODE_ENV === 'production',
external: [
...Object.keys(pkg.dependencies ?? {}),
...Object.keys(pkg?.peerDependencies ?? {}),
],
};

/**
*
Expand All @@ -26,10 +27,9 @@ const getEsbuildPlugin = (format, minify) => {
return esbuild({
format,
tsconfig: './tsconfig.build.json',
sourceMap: false,
treeShaking: true,
platform: 'browser',
target: [ecmascriptLevel],
target: [config.ecmascriptLevel],
minify: minify,
minifyWhitespace: minify, // setting to false allows to create patches
minifyIdentifiers: minify,
Expand All @@ -41,33 +41,33 @@ export default () => [
{
input: ['./src/index.ts'],
preserveModules: true,
external,
external: config.external,
plugins: [getEsbuildPlugin('esm', true)],
output: {
dir: `${distDir}/esm`,
dir: `${config.distDir}/esm`,
format: 'esm',
sourcemap: false,
sourcemap: config.sourceMap,
},
},
// CJS
{
input: ['./src/index.ts'],
preserveModules: false,
external,
external: config.external,
plugins: [getEsbuildPlugin('esm', true)],
output: {
dir: `${distDir}/cjs`,
dir: `${config.distDir}/cjs`,
format: 'cjs',
sourcemap: false,
sourcemap: config.sourceMap,
},
},
// Typings
{
input: './src/index.ts',
output: {
file: `${distDir}/types/index.d.ts`,
file: `${config.distDir}/types/index.d.ts`,
},
external,
external: config.external,
plugins: [
dts({
compilerOptions: {
Expand Down

0 comments on commit 1e98a56

Please sign in to comment.