2

In my package.json file I have the main option where I specify the default include for when you import 'my-index' from 'my-module'

However I want to split my-module into separate files, and let the developer include them individually: import 'my-index/another-file from 'my-module'.

I see one option is to put another-file.js in the root of the my-module repository, but I don't want to place that in the root, I want it in src/another-file.js.

Is there a way to specify this in the package.json file?

Wildhoney
  • 4,969
  • 33
  • 38

1 Answers1

1

You cannot currently do this, instead use either the prepublish and postpublish hooks in the package.json file, or use the postinstall hook. With these you can move the files to the root of your project:

See: Pulling files from a directory into the root folder for NPM

{
    "prepublish": "mv dist/* . && rm -rf dist",
    "postpublish": "rm keo.js redux.js middleware.js"
}

Also do not forget to update the files array in the package.json to reflect the new location of the files, otherwise they won't be included when a developer issues npm i.

Community
  • 1
  • 1
Wildhoney
  • 4,969
  • 33
  • 38