Skip to content

Conversation

yonecdeng
Copy link

use as

    {
        name: '#weblogger',
        var: '',
        path: ``,
    },

@eight04
Copy link
Owner

eight04 commented May 28, 2024

Could you elaborate? Why do you want to replace a variable with an empty string?

@yonecdeng
Copy link
Author

Because there are iife packages that instead of providing a unique global variable, provide many variables mounted to the window. For example: https://cdnjs.cloudflare.com/ajax/libs/tslib/2.6.2/tslib.js

@yonecdeng
Copy link
Author

source:

import {a,b} from 'tslib'
a()
b()

we need change it to:

a()
b()

instead of

tslib.a();
tslib.b();

@eight04
Copy link
Owner

eight04 commented May 29, 2024

I suggest mapping the import to window:

// config
externalGlobals({
  tslib: "window"
})

// source
import {a,b} from 'tslib'
a()
b()

// output
window.a();
window.b();

Replacing an identifier with an empty string may introduce syntax error or undefined variable error in other cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants