Skip to content

Commit

Permalink
abuild: migrate packaging from commonjs to esm
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerpadilla committed Nov 19, 2022
1 parent 6b98859 commit a8893f0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
16 changes: 1 addition & 15 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
import type { JestConfigWithTsJest } from 'ts-jest';
import tsconfig from './tsconfig.json';

const tsConfigPaths = tsconfig.compilerOptions.paths;

const moduleNameMapper = Object.keys(tsConfigPaths).reduce(
(acc, key) => {
const prop = '^' + key.replace('/*', '/(.*)') + '$';
acc[prop] = '<rootDir>/' + tsConfigPaths[key][0].replace('/*', '/$1');
console.log(prop, acc);
return acc;
},
// sourced from https://kulshekhar.github.io/ts-jest/docs/guides/esm-support/#esm-presets
{ '^(\\.{1,2}/.*)\\.js$': '$1' }
);

const jestConfig: JestConfigWithTsJest = {
verbose: true,
extensionsToTreatAsEsm: ['.ts'],
// moduleNameMapper,
moduleNameMapper: {
'^(nukak)/(.*)\\.js$': '<rootDir>/packages/$1/src/$2',
'^(\\.{1,2}/.*)\\.js$': '$1',
},
transform: {
Expand Down
3 changes: 1 addition & 2 deletions packages/nukak-browser/webpack.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable @typescript-eslint/no-var-requires */
import { resolve } from 'node:path';
import { Compiler, Configuration } from 'webpack';
import { Configuration } from 'webpack';
import ResolveTypeScriptPlugin from 'resolve-typescript-plugin';
import tsconfig from '../../tsconfig.json' assert { type: 'json' };

Expand Down

0 comments on commit a8893f0

Please sign in to comment.