question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. Itย collects links to all the places you might be looking at while hunting down a tough bug.

And, if youโ€™re still stuck at the end, weโ€™re happy to hop on a call to see how we can help out.

Plugin development is a bit difficult locally

See original GitHub issue

Choose one: is this a ๐Ÿ› bug report or ๐Ÿ™‹ feature request?

๐Ÿ™‹ Support npm linked plugins!

๐ŸŽ› Configuration (.babelrc, package.json, cli command)

The configuration isnโ€™t important here, but because I canโ€™t link a plugin, I canโ€™t test to see if it works before submitting my package to npm.

๐Ÿค” Expected Behavior

Well, by the description of the problem, it should be supported, I would think!

๐Ÿ˜ฏ Current Behavior

It currently does not support linked plugins.

๐Ÿ’ Possible Solution

I havenโ€™t enough information on how npm link works, but it would be great to learn, since Iโ€™m trying to design something similar in nature to parcel (not a js packager).

๐Ÿ”ฆ Context

I am trying to accomplish creating a plugin locally so that I can start to help parcel support different sorts of file types.

๐Ÿ’ป Code Sample

This is not necessary.

๐ŸŒ Your Environment

Windows 10, latest node, latest npm. I do not use yarn personally.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
elsassphcommented, Jan 20, 2018
  1. Alternative option that Iโ€™m using because Iโ€™m hacking Parceljs:

In your sandbox project, create 2 scripts to manually call Parceljs with your plugin:

// start.js
const Bundler = require('parcel-bundler');

process.env.NODE_ENV = process.env.NODE_ENV || 'development';

// you may be messing quite a bit in a new plugin so you may want to add error capture
process.on('unhandledRejection', (reason, p) => {
    console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
});

// manually set up the bundler
const bundler = new Bundler('./index.html');

bundler.addPackager('ext', require.resolve('./MyPackager'));
bundler.addAssetType('ext', require.resolve('./MyAsset'));

bundler.serve(1234, false);
// build.js
const Bundler = require('parcel-bundler');

process.env.NODE_ENV = 'production';

// you may be messing quite a bit in a new plugin so you may want to add error capture
process.on('unhandledRejection', (reason, p) => {
    console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
});

// manually set up the bundler
const bundler = new Bundler('./index.html');

bundler.addPackager('ext', require.resolve('./MyPackager'));
bundler.addAssetType('ext', require.resolve('./MyAsset'));

bundler.bundle();

Run as node start.js / node build.js.

Iโ€™ve added these scripts to my package.json:

  "scripts": {
    "clean": "rm -rf .cache && rm -rf dist",
    "start": "node script/start.js",
    "build": "node script/build.js"
  },

PS: Iโ€™m on Windows but I have bash commands in my PATH (itโ€™s an option when you install msysgit ).

PPS: never run yarn clean - always yarn run clean

4reactions
elsassphcommented, Jan 20, 2018

I had the same problem - there are different ways to handle that (they could be documented on Parcel website):

  1. Using npm link
  • create a test parceljs project,

  • install your local plugin (this copies your plugin in your test project):

      npm install C:\path\to\parcel-plugin-myplugin
    
  • use npm link to replace the installed copy by a symlink to your plugin sources:

      # in plugin directory
      npm link
      # in your test project directory
      npm link parcel-plugin-myplugin
    

Now you can edit your plugin sources.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is theme & plugin development more difficult than building a ...
Yes, it is. In building a website you use plugins and themes. In developing themes and plugins you have to know HTML, CSS,...
Read more >
Make A WordPress Plugin โ€“ Your Environment - FooPlugins
1. Install WordPress Locally. Installing WordPress locally seems like the logical first step, and besides, you need a way to test the pluginย ......
Read more >
9 Tools You Should Be Using In Your Plugin Development
Run Code: Local Development Programs. While it is possible to develop on a live server, it is incredibly inefficient to do so. It...
Read more >
The Best Setup for Your Local WordPress Development ...
When running a WordPress website it's best practice to at least run a local copy of the site so you can make changes...
Read more >
How to Fix "The site is experiencing technical difficulties."
Contact the plugin or theme's developer and ask if they can edit the extension's code to resolve the conflict. Then update and reactivate...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found