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

Issue 79 - Source maps not accessible #121

Merged
merged 2 commits into from
Jan 5, 2025
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
2 changes: 1 addition & 1 deletion jest.config.js → config/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
roots: ['<rootDir>'],
roots: ['<rootDir>/../'],
transform: {
'\\.(ts|tsx)$': 'ts-jest',
},
Expand Down
9 changes: 2 additions & 7 deletions rollup.config.js → config/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import typescript from '@rollup/plugin-typescript';
import terser from '@rollup/plugin-terser';
import localTypescript from 'typescript';

import pkg from './package.json';
import pkg from '../package.json';

const UMD_CONFIG = {
input: 'src/index.ts',
Expand All @@ -11,12 +11,7 @@ const UMD_CONFIG = {
file: pkg.browser,
format: 'umd',
name: pkg.name,
sourcemap: true,
sourcemapPathTransform(sourcePath) {
const [, sourceFile] = sourcePath.split('/src/');

return `../src/${sourceFile}`;
},
sourcemap: false,
},
plugins: [typescript({ typescript: localTypescript })],
};
Expand Down
19 changes: 19 additions & 0 deletions config/tsconfig/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"allowJs": true,
"baseUrl": "src",
"esModuleInterop": true,
"jsx": "react",
"lib": ["dom", "es2015"],
"module": "esNext",
"moduleResolution": "node",
"noImplicitAny": true,
"noUncheckedIndexedAccess": true,
"outDir": "./dist",
"sourceMap": false,
"strict": true,
"target": "es5"
},
"exclude": ["node_modules"],
"include": ["../../src/*", "../../__tests__/*"]
}
6 changes: 6 additions & 0 deletions config/tsconfig/tsconfig.dev.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"sourceMap": true
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
},
"scripts": {
"benchmark": "npm run dist && NODE_ENV=production node ./benchmarks/index.cjs",
"build": "NODE_ENV=production rollup -c --bundleConfigAsCjs",
"build:mjs": "node ./es-to-mjs.js",
"build": "NODE_ENV=production rollup -c config/rollup.config.js --bundleConfigAsCjs",
"build:mjs": "node scripts/es-to-mjs.js",
"clean": "rimraf dist && rimraf mjs",
"dev": "NODE_ENV=development webpack-dev-server --config=webpack/webpack.config.js",
"dist": "npm run clean && npm run build && npm run build:mjs",
Expand All @@ -95,7 +95,7 @@
"release": "release-it",
"release:beta": "release-it --config=.release-it.beta.json",
"start": "npm run dev",
"test": "NODE_PATH=. jest",
"test": "NODE_PATH=. jest --config=config/jest.config.js",
"test:coverage": "npm run test -- --coverage",
"test:watch": "npm run test -- --watch",
"typecheck": "tsc --noEmit"
Expand Down
12 changes: 2 additions & 10 deletions es-to-mjs.js → scripts/es-to-mjs.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
const fs = require('fs');
const path = require('path');

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

const BASE_PATH = __dirname;
const BASE_PATH = path.resolve(__dirname, '..');
const SOURCE_ENTRY = path.join(BASE_PATH, pkg.module);
const SOURCE_MAP = `${SOURCE_ENTRY}.map`;
const SOURCE_TYPES = path.join(BASE_PATH, 'index.d.ts');
const DESTINATION = 'mjs';
const DESTINATION_ENTRY = path.join(BASE_PATH, DESTINATION, 'index.mjs');
const DESTINATION_MAP = `${DESTINATION_ENTRY}.map`;
const DESTINATION_TYPES = path.join(BASE_PATH, DESTINATION, 'index.d.mts');

function getFilename(filename) {
Expand All @@ -35,12 +33,6 @@ try {
`Copied ${getFilename(SOURCE_ENTRY)} to ${getFilename(DESTINATION_ENTRY)}`,
);

fs.copyFileSync(SOURCE_MAP, DESTINATION_MAP);

console.log(
`Copied ${getFilename(SOURCE_MAP)} to ${getFilename(DESTINATION_MAP)}`,
);

fs.copyFileSync(SOURCE_TYPES, DESTINATION_TYPES);

console.log(
Expand Down
18 changes: 1 addition & 17 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
{
"compilerOptions": {
"allowJs": true,
"baseUrl": "src",
"esModuleInterop": true,
"jsx": "react",
"lib": ["dom", "es2015"],
"module": "esNext",
"moduleResolution": "node",
"noImplicitAny": true,
"noUncheckedIndexedAccess": true,
"outDir": "./dist",
"sourceMap": true,
"strict": true,
"target": "es5"
},
"exclude": ["node_modules"],
"include": ["src/*", "__tests__/*"]
"extends": "./config/tsconfig/tsconfig.base.json"
}