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

deno bundle in 1.5.4 imports and remaps symbols incorrectly #8481

Closed
aricart opened this issue Nov 24, 2020 · 1 comment · Fixed by #8575
Closed

deno bundle in 1.5.4 imports and remaps symbols incorrectly #8481

aricart opened this issue Nov 24, 2020 · 1 comment · Fixed by #8575
Labels
bug Something isn't working correctly cli related to cli/ dir swc related to swc (bundling/transpiling)

Comments

@aricart
Copy link
Contributor

aricart commented Nov 24, 2020

On bundling, symbols are defined, but they seem to be captured incorrectly. Take for example the setUrlParseFn - my library imports that from another library.

On bundling deno the deno bundle rewrites in the mjs like:

line# 369 - the original function in library nats.deno - setUrlParseFn has been remapped to setUrlParseFn2:

let urlParseFn;
function setUrlParseFn2(fn) {
    urlParseFn = fn;
}

line# 1404: - the bundler remaps setUrlParseFn2 to setUrlParseFn1:

const setUrlParseFn1 = setUrlParseFn2;

line# 3951 - code on the nats.ws which imports setUrlParseFn from the nats.deno library, in copied, but not mapped to one of the imported functions (should be setUrlParseFn1?:

function connect2(opts7 = {
}) {
    setUrlParseFn(wsUrlParseFn);
   ^^^^^^^^^^^^^ This symbol has been renamed, to setUrlParse2 or setUrlParse1 - runtime will not find this function
    setTransportFactory(()=>{
        return new WsTransport();
    });
    return NatsConnectionImpl.connect(opts7);
}

Finally on # 7572: - the combined libraries export setUrlParseFn, but while this is the correct name for the re-export, the internal version is not mapped correctly:

export { 
// lots of stuff elided
 setUrlParseFn1 as setUrlParseFn
// more stuff elided
 };

The above is just representative of this symbol. Manually patching them eventually fixes the issue like #8478

@aricart aricart changed the title deno bundle in 1.5.4 exports incorrectly deno bundle in 1.5.4 imports and remaps symbols incorrectly Nov 24, 2020
@aricart
Copy link
Contributor Author

aricart commented Nov 24, 2020

In case you want to generate sample file:

deno bundle https://raw.githubusercontent.com/nats-io/nats.ws/master/src/mod.ts

@bartlomieju bartlomieju added bug Something isn't working correctly cli related to cli/ dir swc related to swc (bundling/transpiling) labels Nov 24, 2020
kdy1 added a commit to kdy1/swc that referenced this issue Nov 27, 2020
@kdy1 kdy1 mentioned this issue Nov 27, 2020
3 tasks
kdy1 added a commit to kdy1/swc that referenced this issue Nov 27, 2020
kdy1 added a commit to swc-project/swc that referenced this issue Nov 27, 2020
swc_bundler:
 - Handle dependencies of circular modules in wrapped modules. (#1214)
 - Handle `export * from './file.ts'` properly. (denoland/deno#8481)
 - Fix deglobbing. (denoland/deno#8486)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly cli related to cli/ dir swc related to swc (bundling/transpiling)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants