Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add sourcemaps #16

Merged
merged 3 commits into from
Sep 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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