momocow / webpack-userscript

A Webpack plugin for userscript projects. 🙈
https://cow.moe/webpack-userscript/
MIT License
200 stars 21 forks source link

[feature] Export `HeadersProvider` at top level #85

Closed vitoyucepi closed 1 year ago

vitoyucepi commented 1 year ago

Summary

I'd like to add type for a standalone function.

Here's how I can do it now

import WebpackUserscript from 'webpack-userscript';
import {HeadersProvider} from 'webpack-userscript/dist/features';

const userScriptHeadersProvider: HeadersProvider = (headers) => {
  console.log(headers);
  headers.version += '-test'
  return headers;
};

const plugin = new WebpackUserscript({headers: userScriptHeadersProvider});

Versions

Webpack: 5.76.0 Webpack-userscript: 3.0.1

Additional

Maybe it'll be a good idea to move HeadersProvider to types.ts? https://github.com/momocow/webpack-userscript/blob/96cf022227ba5e306628334a7477743bb22351d4/lib/features/load-headers.ts#L14-L17

momocow commented 1 year ago

Maybe it'll be a good idea to move HeadersProvider to types.ts?

Nope, it should be in the place where it is consumed to keep the modularity. The load-headers feature is responsible for defining how it looks like.

I'll re-export it in the types.ts instead of moving it, along with other options-related types.

inazuma-bot commented 1 year ago

:tada: This issue has been resolved in version 3.1.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: