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

fix(core): generate es exports dts files correctly #212

Merged
merged 1 commit into from
Jun 15, 2021
Merged

fix(core): generate es exports dts files correctly #212

merged 1 commit into from
Jun 15, 2021

Conversation

lihbr
Copy link
Contributor

@lihbr lihbr commented Jun 15, 2021

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

Versions

  • siroc: v0.11.0 (latest)
  • node: v14.15.3 && 16.3.0

Reproduction

Steps to reproduce

  1. Use this package.json export schema:
{
	"exports": {
		".": {
    		"require": "./dist/index.cjs",
    		"import": "./dist/index.es.js"
    	},
    	"./graphql": {
    		"require": "./dist/graphql/index.cjs",
    		"import": "./dist/graphql/index.es.js"
    	}
	}
}
  1. Build with siroc build

What is Expected?

  dist/
  ├── graphql/
  │   ├── index.cjs
  │   ├── index.d.ts
  │   └── index.es.js
  ├── index.cjs
  ├── index.d.ts
  └── index.es.js

What is actually happening?

  dist/
  ├── graphql/
  │   ├── index.cjs
- │   ├── index.es.d.ts
  │   └── index.es.js
  ├── index.cjs
- ├── index.es.d.ts
  └── index.es.js

This prevents TypeScript from picking up definition files correctly, filling the types field on the package.json file only fixes the top-level definition file.

Patch

I extended the RegExp to optionally replace .es suffixes if present, fixing the issue.

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (PR: #)
  • All new and existing tests are passing.

ps: that'd be cool if you can also check #211, it's been a month and with this one those are two quick patches, let me know how I can help if needed :(

cc @pi0, @danielroe, @angeloashmore

@lihbr lihbr changed the title fix(core): preserve package.json indent fix(core): generate-es-exports-dts-files-correctly Jun 15, 2021
@danielroe danielroe merged commit b0f29c6 into danielroe:main Jun 15, 2021
@lihbr lihbr deleted the fix/generate-es-exports-dts-files-correctly branch June 15, 2021 18:11
@lihbr lihbr changed the title fix(core): generate-es-exports-dts-files-correctly fix(core): generate es exports dts files correctly Aug 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants