Skip to content

Commit

Permalink
Merge pull request #247 from jacob-alford/ja/fix-fp-ts-imports
Browse files Browse the repository at this point in the history
chore: fix esmodules
  • Loading branch information
jacob-alford authored Feb 2, 2023
2 parents 81576dc + 237c772 commit 763989e
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 16 deletions.
15 changes: 12 additions & 3 deletions .babel.cjs.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
{
"plugins": [
"@babel/transform-modules-commonjs",
"@babel/plugin-proposal-export-namespace-from",
"annotate-pure-calls"
["@babel/transform-modules-commonjs"],
["@babel/plugin-proposal-export-namespace-from"],
["annotate-pure-calls"],
[
"transform-rename-import",
{
"replacements": [
{ "original": "^fp-ts/(\\w*)$", "replacement": "fp-ts/lib/$1.js" },
{ "original": "^io-ts/(\\w*)$", "replacement": "io-ts/lib/$1.js" }
]
}
]
]
}
13 changes: 12 additions & 1 deletion .babel.esm.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
{
"plugins": ["annotate-pure-calls"]
"plugins": [
["annotate-pure-calls"],
[
"transform-rename-import",
{
"replacements": [
{ "original": "^fp-ts/(\\w*)$", "replacement": "fp-ts/es6/$1.js" },
{ "original": "^io-ts/(\\w*)$", "replacement": "io-ts/es6/$1.js" }
]
}
]
]
}
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "schemata-ts",
"version": "1.2.2",
"version": "1.2.3",
"description": "A collection of Schemata inspired by io-ts-types and validators.js",
"homepage": "https://jacob-alford.github.io/schemata-ts/",
"repository": {
Expand All @@ -14,16 +14,18 @@
"access": "public"
},
"main": "./dist/index.js",
"module": "./dist/esm/index.mjs",
"module": "./dist/_esm/index.mjs",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/esm/index.mjs",
"node": "./dist/index.js",
"import": "./dist/_esm/index.mjs",
"require": "./dist/index.js"
},
"./*": {
"types": "./dist/*.d.ts",
"import": "./dist/esm/*.mjs",
"node": "./dist/*.js",
"import": "./dist/_esm/*.mjs",
"require": "./dist/*.js"
}
},
Expand Down Expand Up @@ -85,6 +87,7 @@
"@typescript-eslint/eslint-plugin": "^4.25.0",
"@typescript-eslint/parser": "^4.25.0",
"babel-plugin-annotate-pure-calls": "^0.4.0",
"babel-plugin-transform-rename-import": "^2.3.0",
"colorette": "^2.0.19",
"concurrently": "^7.2.2",
"cspell": "^5.5.2",
Expand Down
16 changes: 11 additions & 5 deletions scripts/pack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,16 @@ export const copyPackageJson: Build<void> = C =>
exports: {
'.': {
types: './index.d.ts',
node: './index.js',
import: './_esm/index.mjs',
require: './index.js',
},
'./*': { types: './*.d.ts', import: './_esm/*.mjs', require: './*.js' },
'./*': {
types: './*.d.ts',
node: './*.js',
import: './_esm/*.mjs',
require: './*.js',
},
},
publishConfig: {
access: 'public',
Expand Down Expand Up @@ -78,9 +84,9 @@ export const rewriteSourceMap: (
? v.map(source => {
let clone = `${source}`
if (path_.match(/dist\/_(.+)\//)) {
clone = clone.replace(/(.*)\.\.\/src(.*)/gm, '$1_src$2')
clone = clone.replace(/(.*)\.\.\/src(.*)/gm, '$1src$2')
} else {
clone = clone.replace(/(.*)\.\.\/\.\.\/src(.*)/gm, '$1_src$2')
clone = clone.replace(/(.*)\.\.\/\.\.\/src(.*)/gm, '$1src$2')
}
clone = path.posix.relative(dir, path.posix.join(dir, clone))
return clone.startsWith('.') ? clone : './' + clone
Expand All @@ -104,8 +110,8 @@ export const copyMetaFiles: Build<ReadonlyArray<void>> = C =>

export const copyBuildFiles: Build<void> = C =>
pipe(
C.mkdir(`./dist/_src`),
TE.chain(() => C.exec('cp -r ./src/* ./dist/_src')),
C.mkdir(`./dist/src`),
TE.chain(() => C.exec('cp -r ./src/* ./dist/src')),

/* Copy build/esm to dist/_esm */
TE.chain(() => C.mkdir('./dist/_esm')),
Expand Down
2 changes: 1 addition & 1 deletion src/schemata/boolean/BooleanFromNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @since 1.0.0
*/
import { boolean } from 'io-ts/lib/Guard'
import { boolean } from 'io-ts/Guard'
import { make, SchemaExt } from 'schemata-ts/SchemaExt'

/**
Expand Down
2 changes: 1 addition & 1 deletion src/schemata/boolean/BooleanFromString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @since 1.0.0
*/
import { pipe } from 'fp-ts/function'
import { boolean } from 'io-ts/lib/Guard'
import { boolean } from 'io-ts/Guard'
import * as PB from 'schemata-ts/PatternBuilder'
import { make, SchemaExt } from 'schemata-ts/SchemaExt'

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"stripInternal": true,
"module": "ESNext",
"target": "ESNext",
"tsBuildInfoFile": "./dist/tsconfig.build.tsbuildinfo"
"tsBuildInfoFile": "./build/tsconfig.build.tsbuildinfo"
},
"include": ["./src"],
"exclude": ["src/__tests__/*.ts"]
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2231,6 +2231,11 @@ babel-plugin-polyfill-regenerator@^0.4.0:
dependencies:
"@babel/helper-define-polyfill-provider" "^0.3.2"

babel-plugin-transform-rename-import@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-rename-import/-/babel-plugin-transform-rename-import-2.3.0.tgz#5d9d645f937b0ca5c26a24b2510a06277b6ffd9b"
integrity sha512-dPgJoT57XC0PqSnLgl2FwNvxFrWlspatX2dkk7yjKQj5HHGw071vAcOf+hqW8ClqcBDMvEbm6mevn5yHAD8mlQ==

babel-preset-current-node-syntax@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz#b4399239b89b2a011f9ddbe3e4f401fc40cff73b"
Expand Down

0 comments on commit 763989e

Please sign in to comment.