Naming the library and working with Node.js

As explained, we are now in the last steps of this authoring. The optimization of the output should be made by following the guide as we proceed. While we do this, we will add in the path to the bundle output as the package's main field with the package.json file, as follows:

{
...
"main": "dist/numbers-to-text.js",
...
}
Or, to add as standard module as per this guide:
{
...
"module": "src/index.js",
...
}

The option key named "main" in the preceding code block refers to the standard we retrieve from the package.json file. The "module" key refers to a proposal that allows the JavaScript environment to upgrade, to be able to use ES2015 modules without harming any backward-compatibility capabilities.

In the case of the "module" property, this should point to a script that uses ES2015 module syntax throughout, but no other syntax that is not yet supported by browsers or Node.js. This will enable Webpack to parse module syntax and allow lighter bundles through tree shaking, as users are likely only consuming certain parts of any given library.

Once this is done, the bundle can be published as an npm package.

You have learned how to set up and configure your first custom library using a JSON file with corresponding numbers and text, including exposing the new library in your frontend and specifying the limitations in scope for the library. 

In a related sphere, let's now talk about custom loaders.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.233.58