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.

Overriding core plugin lifecycle methods

See original GitHub issue

The core @netlify/functions plugin exposes a buildFunctions hook.

I had some logic included (before the refactor) that would allow for plugins to hook in and override the default functionality

This was the override plugin

function newFunctionsPlugin(conf) {
  return {
    '@netlify/functions:buildFunctions': () => {
      console.log('do my custom function thing')
    },
  }
}
module.exports = newFunctionsPlugin

@netlify/functions:buildFunctions was detected when constructing the build lifecycle and overrode the default function (located in @netlify/functions)

The old functionality was here: https://github.com/netlify/build/blob/401cca33085c844886e60177de4e1a4ef4917f38/packages/build-core/src/build.js#L414-L416

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
DavidWellscommented, Oct 4, 2019

the override is using the plugin ID but I am realizing this does not make sense. We should use the package name. Is that correct?

Yeah I think it needs to be the package name because users can name the logicalId anything they want.

the overridden plugin must be defined before the plugin that overrides it. I think this was the original behavior but is this intended?

Yeah the order matters right now.


Sidenote: It’s also possible for users to override plugins like this:

const whateverPlugin = require('the-plugin')

module.exports = function myPluginWithOverride() {
  const originalPlugin = whateverPlugin({ foo: 'bar'})

  return Object.assign({}, originalPlugin, {
    postBuild: () => { /* change originalPlugin postBuild */}
  })
}
plugins:
   myPluginWithOverride:
      type: /plugins/myPluginWithOverride.js
      config: ...

This makes plugins very flexible for users to customize

0reactions
ehmickycommented, Oct 7, 2019

Fixed by #204.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Overriding Core Classes with Ext Plugins - Liferay Help Center
Overriding Core Classes with Ext Plugins · Navigate to your Liferay Workspace's root folder and run the following command: · Displaying the server...
Read more >
How to override Android lifecycle related functions from within ...
There is an abstract onResume() method in the CordovaPlugin class which you can override like this: @Override public void onResume(boolean ...
Read more >
Handling Lifecycles with Lifecycle-Aware Components
Lifecycle -aware components perform actions in response to a change in the lifecycle status of another component, such as activities and ...
Read more >
Overrides - PrestaShop Developer Documentation
Overrides. Overriding is a way to “override” class files and controller files. PrestaShop's ingenious class auto-loading function makes the “switch” to ...
Read more >
Implementing Gradle plugins
Knowledge of Gradle fundamentals like project organization, task creation and configuration as well as the Gradle build lifecycle. Working knowledge in writing ...
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