Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made generateConfig public and switched order of merge #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

CEbbinghaus
Copy link

My config requires plugins ordered in a particular order which makes using the preset as it is right now impossible.

import plugin from "./plugin.json" with { type: "json" };

export default defineConfig(merge(
	deckyPlugin(),
	{
		plugins: [
			nodeResolve({ browser: true }),
			codegen.default(),
			mdx({ providerImportSource: '@mdx-js/react' }),
			commonjs(),
			json(),
			typescript(),
			externalGlobals({
				react: 'SP_REACT',
				'react-dom': 'SP_REACTDOM',
				'@decky/ui': 'DFL',
				'@decky/manifest': JSON.stringify(plugin)
			}),
			replace({
				preventAssignment: false,
				'process.env.NODE_ENV': JSON.stringify('production'),
			}),
			importAssets({
				publicPath: `http://127.0.0.1:1337/plugins/${plugin.name}/`
			})
		],
	}
));

To help with this I propose 2 changes

  • export the generateConfig method so the file reading can be skipped if the config is already known:
import plugin from "./plugin.json" with { type: "json" };

export default defineConfig(merge(
	generateConfig(plugin),
	...
	)
)
  • Switch around the order the arguments are provided to mergeAndConcat which means that the provided arguments actually override the base argument.
// Should override input with "test.ts" rather than the default
deckyPlugin({input: "test.ts"});

@CEbbinghaus
Copy link
Author

I didn't add it yet but I would also like an option to provide the config as an object rather than having the deckyPlugin method read the file itself.

-export default function deckyPlugin(options = {}, sourceRoot = ".") {
-    const manifest = JSON.parse(readFileSync(join(sourceRoot, "plugin.json"), "utf-8"));
+export default function deckyPlugin(options = {}, plugin = undefined) {
+    const manifest = plugin || JSON.parse(readFileSync(join(sourceRoot, "plugin.json"), "utf-8"));
    const defaultOptions = generateConfig(manifest);

@TrainDoctor TrainDoctor added the enhancement New feature or request label Sep 15, 2024
@CEbbinghaus
Copy link
Author

Ideally we would also change the mergeAndConcat to just merge so I can skip having to do the merge myself. I need to purely overwrite the plugin order not merely add to it. If that were done I could switch to using this package as intended although with the downside that it still reads the file itself.

@TrainDoctor TrainDoctor requested a review from beebls September 17, 2024 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 🆕 New
Development

Successfully merging this pull request may close these issues.

2 participants