Skip to content

Commit b4e3c52

Browse files
authored
chore: update npm packages (marpple#188)
* chore: update npm packages * chore: prettier * Fix/187 (marpple#189) * build: add types field in package.json exports * fix: fix build that incorrectly imported the 'tslib' inside the 'esm' package
1 parent 711c8b6 commit b4e3c52

8 files changed

+611
-594
lines changed

build/generateExports.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@ import { drop, map, not, pipe, reduce } from "../src/index";
44

55
const SOURCE_DIR = "./src";
66
const OUTPUT_DIR = "./dist";
7+
const TYPES_ROOT_DIR = `${OUTPUT_DIR}/types`;
78
const CJS_ROOT_DIR = `${OUTPUT_DIR}/cjs`;
89
const ESM_ROOT_DIR = `${OUTPUT_DIR}/esm`;
910
const ESM5_ROOT_DIR = `${OUTPUT_DIR}/esm5`;
1011

1112
const conditionalRootIndex = {
13+
types: `${TYPES_ROOT_DIR}/index.d.ts`,
1214
import: `${ESM_ROOT_DIR}/index.js`,
1315
require: `${CJS_ROOT_DIR}/index.js`,
1416
};
1517

1618
const conditionalRootIndexLazy = {
19+
types: `${TYPES_ROOT_DIR}/Lazy/index.d.ts`,
1720
import: `${ESM_ROOT_DIR}/Lazy/index.js`,
1821
require: `${CJS_ROOT_DIR}/Lazy/index.js`,
1922
};
@@ -52,6 +55,7 @@ async function generateExports() {
5255
fileNames,
5356
map((name) => {
5457
const conditionalSubPaths = {
58+
types: `${TYPES_ROOT_DIR}/${name}.d.ts`,
5559
import: `${ESM_ROOT_DIR}/${name}.js`,
5660
require: `${CJS_ROOT_DIR}/${name}.js`,
5761
};
@@ -84,8 +88,9 @@ async function generateExports() {
8488

8589
(async function main() {
8690
await Promise.all([
87-
// Add package.json file to cjs directory
88-
writeFile(`${CJS_ROOT_DIR}/package.json`, '{ "type": "commonjs" }'),
91+
// Add package.json file to esm/esm5 directory
92+
writeFile(`${ESM_ROOT_DIR}/package.json`, '{ "type": "module" }'),
93+
writeFile(`${ESM5_ROOT_DIR}/package.json`, '{ "type": "module" }'),
8994
// Generate and add 'exports' field to root package.json
9095
generateExports(),
9196
]);

build/generateExtensions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ async function main() {
2121
])
2222
.map(async (promise) => {
2323
const [path, file] = await promise;
24-
const importRegex = /import [\w,{}\s\n_*]+ from "[\w,{}\s\n./_]+";/gi;
24+
const importRegex = /import [\w,{}\s\n_*]+ from "\.[\w,{}\s\n./_]+";/gi;
2525
const exportRegex = /export [\w,{}\s\n_*]+ from "[\w,{}\s\n./_]+";/gi;
2626
const statements = (file.match(importRegex) || []).concat(
2727
file.match(exportRegex) || ([] as any),

0 commit comments

Comments
 (0)