Skip to content

Best way to handle commonjs conditional re-exports? #952

Answered by rschristian
chopfitzroy asked this question in Q&A
Discussion options

You must be logged in to vote

Sure, easiest would be to use @rollup/replace-plugin. Just install it and modify your wmr.config.mjs to look a little like the following:

// wmr.config.mjs
import { defineConfig } from 'wmr';
import replace from '@rollup/replace-plugin';

// Full list of options: https://wmr.dev/docs/configuration
export default defineConfig({
	/* Your configuration here */
	alias: {
		react: 'preact/compat',
		'react-dom': 'preact/compat'
	},
        plugins: [
                replace({ 'use-sync-external-store/shim/index.js': 'preact/compat' }),
        ],
});

This (more or less) directly swaps string values. A bit less refined than an alias, but still very effective (and necessary in this case).

Hope i…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@chopfitzroy
Comment options

Answer selected by chopfitzroy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants