iamkun / dayjs

⏰ Day.js 2kB immutable date-time library alternative to Moment.js with the same modern API
https://day.js.org
MIT License
46.99k stars 2.3k forks source link

Documentation for custom plugins might not be up to date #1484

Open tbyte80 opened 3 years ago

tbyte80 commented 3 years ago

On this page: https://day.js.org/docs/en/plugin/plugin a template is provided how to create a custom plugin.

However, if I create a simple test plugin:

export default (option, dayjsClass, dayjsFactory) => {
  dayjsClass.prototype.foo= function() {  return 'foo'; }
}

and import it using:

var foo= require('my-dayjs-plugins/foo/index')
dayjs.extend(foo) // use plugin

I get the error: Uncaught TypeError: t is not a function

What am I doing wrong?

iamkun commented 3 years ago

a reproduction demo, pls