@@ -224,7 +224,7 @@ in your project's `package.json`.
224224
225225## Package entry points
226226
227- In a package’ s ` package.json ` file, two fields can define entry points for a
227+ In a package' s ` package.json ` file, two fields can define entry points for a
228228package: [ ` "main" ` ] [ ] and [ ` "exports" ` ] [ ] . The [ ` "main" ` ] [ ] field is supported
229229in all versions of Node.js, but its capabilities are limited: it only defines
230230the main entry point of the package.
@@ -255,7 +255,7 @@ likely be a breaking change.**
255255
256256To make the introduction of [ ` "exports" ` ] [ ] non-breaking, ensure that every
257257previously supported entry point is exported. It is best to explicitly specify
258- entry points so that the package’ s public API is well-defined. For example,
258+ entry points so that the package' s public API is well-defined. For example,
259259a project that previous exported ` main ` , ` lib ` ,
260260` feature ` , and the ` package.json ` could use the following ` package.exports ` :
261261
@@ -303,7 +303,7 @@ path `import feature from 'my-mod/feature/index.js`.
303303### Main entry point export
304304
305305To set the main entry point for a package, it is advisable to define both
306- [ ` "exports" ` ] [ ] and [ ` "main" ` ] [ ] in the package’ s [ ` package.json ` ] [ ] file:
306+ [ ` "exports" ` ] [ ] and [ ` "main" ` ] [ ] in the package' s [ ` package.json ` ] [ ] file:
307307
308308``` json
309309{
@@ -745,8 +745,8 @@ changes:
745745 description: Unflag self-referencing a package using its name.
746746-->
747747
748- Within a package, the values defined in the package’ s
749- ` package.json ` [ ` "exports" ` ] [ ] field can be referenced via the package’ s name.
748+ Within a package, the values defined in the package' s
749+ ` package.json ` [ ` "exports" ` ] [ ] field can be referenced via the package' s name.
750750For example, assuming the ` package.json ` is:
751751
752752``` json
@@ -950,7 +950,7 @@ This approach is appropriate for any of the following use cases:
950950 install both this package and those other packages. For example a ` utilities `
951951 package is used directly in an application, and a ` utilities-plus ` package
952952 adds a few more functions to ` utilities ` . Because the wrapper exports
953- underlying CommonJS files, it doesn’ t matter if ` utilities-plus ` is written in
953+ underlying CommonJS files, it doesn' t matter if ` utilities-plus ` is written in
954954 CommonJS or ES module syntax; it will work either way.
955955* The package stores internal state, and the package author would prefer not to
956956 refactor the package to isolate its state management. See the next section.
@@ -960,7 +960,7 @@ be to add an export, e.g. `"./module"`, to point to an all-ES module-syntax
960960version of the package. This could be used via ` import 'pkg/module' ` by users
961961who are certain that the CommonJS version will not be loaded anywhere in the
962962application, such as by dependencies; or if the CommonJS version can be loaded
963- but doesn’ t affect the ES module version (for example, because the package is
963+ but doesn' t affect the ES module version (for example, because the package is
964964stateless):
965965
966966``` json
@@ -994,22 +994,22 @@ points directly:
994994
995995This can be done if both the CommonJS and ES module versions of the package are
996996equivalent, for example because one is the transpiled output of the other; and
997- the package’ s management of state is carefully isolated (or the package is
997+ the package' s management of state is carefully isolated (or the package is
998998stateless).
999999
10001000The reason that state is an issue is because both the CommonJS and ES module
10011001versions of the package might get used within an application; for example, the
1002- user’ s application code could ` import ` the ES module version while a dependency
1002+ user' s application code could ` import ` the ES module version while a dependency
10031003` require ` s the CommonJS version. If that were to occur, two copies of the
10041004package would be loaded in memory and therefore two separate states would be
10051005present. This would likely cause hard-to-troubleshoot bugs.
10061006
1007- Aside from writing a stateless package (if JavaScript’ s ` Math ` were a package,
1007+ Aside from writing a stateless package (if JavaScript' s ` Math ` were a package,
10081008for example, it would be stateless as all of its methods are static), there are
1009- some ways to isolate state so that it’ s shared between the potentially loaded
1009+ some ways to isolate state so that it' s shared between the potentially loaded
10101010CommonJS and ES module instances of the package:
10111011
1012- 1 . If possible, contain all state within an instantiated object. JavaScript’ s
1012+ 1 . If possible, contain all state within an instantiated object. JavaScript' s
10131013 ` Date ` , for example, needs to be instantiated to contain state; if it were a
10141014 package, it would be used like this:
10151015
@@ -1019,7 +1019,7 @@ CommonJS and ES module instances of the package:
10191019 // someDate contains state; Date does not
10201020 ```
10211021
1022- The ` new ` keyword isn’ t required; a package’ s function can return a new
1022+ The ` new ` keyword isn' t required; a package' s function can return a new
10231023 object, or modify a passed-in object, to keep the state external to the
10241024 package.
10251025
@@ -1046,7 +1046,7 @@ CommonJS and ES module instances of the package:
10461046 each reference of ` pkg ` will contain the same state; and modifying that
10471047 state from either module system will apply to both.
10481048
1049- Any plugins that attach to the package’ s singleton would need to separately
1049+ Any plugins that attach to the package' s singleton would need to separately
10501050attach to both the CommonJS and ES module singletons.
10511051
10521052This approach is appropriate for any of the following use cases:
@@ -1121,7 +1121,7 @@ changes:
11211121}
11221122```
11231123
1124- The ` "name" ` field defines your package’ s name. Publishing to the
1124+ The ` "name" ` field defines your package' s name. Publishing to the
11251125_ npm_ registry requires a name that satisfies
11261126[ certain requirements] ( https://docs.npmjs.com/files/package.json#name ) .
11271127
@@ -1202,7 +1202,7 @@ Files ending with `.js` are loaded as ES modules when the nearest parent
12021202` "module" ` .
12031203
12041204The nearest parent ` package.json ` is defined as the first ` package.json ` found
1205- when searching in the current folder, that folder’ s parent, and so on up
1205+ when searching in the current folder, that folder' s parent, and so on up
12061206until a node\_ modules folder or the volume root is reached.
12071207
12081208``` json
0 commit comments