1.0.2 • Published 3 years ago

@hwbdev/exports v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

This package demonstrates the exports field in package.json. There are two ways to specify entry points to a package: the 'main' and 'exports' field.

  • 'exports' map a name to a path, so that whenever that name is imported, the file at the specified path is used. 'exports' prevents external packages from importing any files that are not specified in 'exports'.
  • 'main' specifies the file to import when the name of the package is specified (as opposed to a file within the package).

'exports' takes precedence of 'main'.

For example, if an external package has var mod = require('@hwbdev/exports'), entrypoint1.js will actually run. If 'exports' wasn't defined, main.js will be the one that runs. Where as if the external package has var mod = require('@hwbdev/exports/entrypoint1'), main.js will be the one that runs. If 'exports' wasn't defined, entrypoint1.js will be the one that runs. If the external package has var mod = require('@hwbdev/exports/unaccessible'), an error will show up. If 'exports' wasn't defined, unaccessible.js will run.

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago