Struggling to find a solution using a parcel
-based approach, I opted for an alternative method utilizing npm
:
To begin, I established a directory named local_modules
(which can be named anything desired). Within this directory, I created a subfolder called parcel-plugin-x
. Within the plugin folder, I proceeded to develop my plugin as usual. Additionally, I crafted a package.json
file specifying the main entry point. Dependencies required for the module were also defined in a manner similar to that of a standalone project.
{
"name": "parcel-plugin-x",
"version": "0.1.0",
"description": "Parcel plugin x",
"main": "index.js",
"devDependencies": {
},
"dependencies": {
}
}
Directory organization:
project-folder
|---local_modules
|---parcel-plugin-x
|---index.js
|---package.json
|---package.json
Subsequently, running
npm i --save-dev .local_modules/parcel-plugin-x
within the
project-folder
enabled the addition of
"parcel-plugin-x": "./local_modules/parcel-plugin-x",
to the root
package.json
. This practice adheres to the standard protocol for loading local modules in npm. Any modifications made to the plugin mandate running
npm upgrade
, along with incrementing the version number of the plugin. This process facilitates copying the plugin to
node_modules
and installing necessary dependencies.
Per the documentation from parceljs:
Any dependencies specified in package.json with designated prefixes will automatically load during initialization.
With these adjustments implemented, the solution now operates seamlessly! :)