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

minify=true will generate error code? #1091

Open
codedaybyday opened this issue Mar 7, 2024 · 0 comments
Open

minify=true will generate error code? #1091

codedaybyday opened this issue Mar 7, 2024 · 0 comments

Comments

@codedaybyday
Copy link

codedaybyday commented Mar 7, 2024

demo:

async function getClient() {
    return await {
        call: (data) => {console.log('call', data)}
    };
}

async function test(data: string) {
    const client = await getClient();
    await client?.call(data);
    return true;
}
test("1");

tsup.config.json

import {defineConfig} from 'tsup';

process.env.NODE_ENV = 'development';


export default defineConfig([
    {
        entry: ['./index.ts'],
        format: ['cjs'],
        splitting: true,
        sourcemap: true,
        minify: true,
        outDir: './dist/',
        noExternal: [],
        define: {
        },
        plugins: [
        ],
        target: 'es2020',
        tsconfig: './tsconfig.json'
    }
]);

tsconfig.json

{
    "compilerOptions": {
        "types": ["node"],
        "target": "ES2022",
        "paths": {
        },
        "typeRoots": [
        ]
    },
    "include": [
    ],
    "exclude": ["node_modules"]
}

run dist/index.js

the error:

"use strict"; async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }async function n(){return await{call:t=>{console.log("call",t)}}}async function a(t){return awaitawait _asyncOptionalChain([(await n()), 'optionalAccess', async _ => _.call, 'call', async _2 => _2(t)]),!0}a("1");
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ^^^^^^^^^^^^^^^^^^^

SyntaxError: Unexpected identifier
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1178:20)
    at Module._compile (node:internal/modules/cjs/loader:1220:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)
    at node:internal/main/run_main_module:23:47

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
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

No branches or pull requests

1 participant