Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

The `package.json` is missing the `main` or `exports` fields

Abierto
#889 0 comentarios 7 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
52/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
javascript
Área
build-system

Línea de trabajo

Comienza inspeccionando package.json, la carpeta dist existente y el punto de entrada index.js referenciado. Comprueba el contenido del paquete que se publicaría y cómo se consume la salida actual de la compilación; se considera terminado únicamente cuando solo se distribuyen los archivos dist previstos y las importaciones del paquete se resuelven en el punto de entrada transpilado.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Issue

The package.json doesn't filter what files should be packaged and sent the NPM. Therefore, all the source code with .less files is being distributed.

Also, the entry point of the package is not specified using main, module, or exports. That way, it's confusing for the bundlers what should be used and usually they start picking the files from the src:
https://github.com/NUKnightLab/TimelineJS3/blob/c5948d41fd333a1d292ec1c497c38e52ef793013/index.js#L1

So it requires to double-transpile the package in the consuming app and they don't benefit from the transpilation done before publishing anyway 😢

Suggested changes

  1. Limit the distributed code only to the dist folder. That will significantly reduce the size of the package.
  2. Specify an entry point explicitly and it should point to the transpiled files in the dist.

Smth like this[^1]:

{
  "name": "@knight-lab/timelinejs",
  "version": "4.0.0",
  "type": "module",
  "files": [
    "dist"
  ],
  "exports": {
    ".": {
      "import": "./dist/index.js"
    }
  },
  "main": "./dist/index.js",
  ...  
Config breakdown

Node has already come up with the following package.json properties that allow to limit what will get published to NPM:

  • files - "an array of file patterns that describes the entries to be included when your package is installed as a dependency"
  • main - "a module ID that is the primary entry point to your program. That is, if your package is named foo, a user installs it, and then does require("foo")"
  • types - Set the types property to point to your bundled declaration file.
  • exports - "defining the entry points of a package. An alternative to the "main" that can support defining "subpath exports" and "conditional exports".

Lenguaje dominante
JavaScript
Estrellas
3.2k
Forks
645
Merge medio
3 min
PR fusionados (30 d)
2

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de NUKnightLab/TimelineJS3

Todos los issues de NUKnightLab/TimelineJS3

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.