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

feat(octicons-react): add files to package.json and update npmignore #895

Merged
merged 3 commits into from
Jan 17, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/mighty-berries-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/octicons-react": minor
---

Update the npm package for `@primer/octicons-react` to include the `exports` field and explicitly list out files in `package.json`
4 changes: 3 additions & 1 deletion lib/octicons_react/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
.next
script
src
./pages
**/pages/**
**/__tests__/**
**/ts-tests/**
8 changes: 8 additions & 0 deletions lib/octicons_react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"license": "MIT",
"main": "dist/index.umd.js",
"module": "dist/index.esm.js",
"exports": {
"import": "dist/index.esm.js",
"require": "dist/index.umd.js"
},
Comment on lines +10 to +13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi I now get an error when running next build

> next build

info  - Skipping validation of types
info  - Linting  
info  - Creating an optimized production build  
info  - Compiled successfully
info  - Collecting page data .Error [ERR_INVALID_PACKAGE_TARGET]: Invalid "exports" main target "dist/index.umd.js" defined in the package config /node_modules/@primer/octicons-react/package.json; targets must start with "./"
    at new NodeError (node:internal/errors:400:5)
    at invalidPackageTarget (node:internal/modules/esm/resolve:389:10)
    at resolvePackageTargetString (node:internal/modules/esm/resolve:445:11)
    at resolvePackageTarget (node:internal/modules/esm/resolve:522:12)
    at resolvePackageTarget (node:internal/modules/esm/resolve:571:31)
    at packageExportsResolve (node:internal/modules/esm/resolve:635:27)
    at resolveExports (node:internal/modules/cjs/loader:538:36)
    at Module._findPath (node:internal/modules/cjs/loader:607:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1025:27)
    at mod._resolveFilename (/Users/gr2m/code/github/howie/app/node_modules/next/dist/build/webpack/require-hook.js:27:32) {
  code: 'ERR_INVALID_PACKAGE_TARGET'
}

I think these should be

  "exports": {
    "import": "./dist/index.esm.js",
    "require": "./dist/index.umd.js"
  },

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirmed that making the change resolves the problem

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there you go #905

"sideEffects": false,
"types": "dist/index.d.ts",
"repository": "primer/octicons",
Expand All @@ -19,6 +23,10 @@
"ts-test": "tsc -P ts-tests",
"posttest": "yarn ts-test"
},
"files": [
"build",
"dist"
],
"keywords": [
"GitHub",
"icons",
Expand Down