swc icon indicating copy to clipboard operation
swc copied to clipboard

Incorrect generation output upon running swc on root directory

Open isRyven opened this issue 2 years ago • 0 comments

Describe the bug

Upon running swc on root of my package directory, i am getting broken js entry file.

npx swc --version
@swc/cli: 0.1.57
@swc/core: 1.2.242

npx swc $PWD -d dist
Successfully compiled: 150 files with swc (217.32ms)

dist/index.js

"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
_exportStar(require("./web-app"), exports);
_exportStar(require("./middlewares"), exports);
_exportStar(require("./routing"), exports);
_exportStar(require("./http-config"), exports);
_exportStar(require("./context-accessor"), exports);
_exportStar(require("./utils"), exports);
_exportStar(require("./request-context-accessor"), exports);
_exportStar(require("./stub-context-accessor"), exports);
function _exportStar(from, to) {
    Object.keys(from).forEach(function(k) {
        if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
            enumerable: true,
            get: function() {
                return from[k];
            }
        });
    });
    return from;
}

//# sourceMappingURL=index.js.map         return from[k];
            }
        });
    });
    return from;
}

//# sourceMappingURL=index.js.map         get: function() {
                return from[k];
            }
        });
    });
    return from;
}

//# sourceMappingURL=index.js.mapb"), exports);
_exportStar(require("./translation"), exports);
_exportStar(require("./config"), exports);
function _exportStar(from, to) {
    Object.keys(from).forEach(function(k) {
        if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
            enumerable: true,
            get: function() {
                return from[k];
            }
        });
    });
    return from;
}

//# sourceMappingURL=index.js.map

Actual index.ts is just this:


export * from './authentication';
export * from './persistence';
export * from './logging';
export * from './infrastructure';
export * from './domain';
export * from './values';
export * from './domain/rules';
export * from './command';
export * from './query';
export * from './migration';
export * from './amqp';
export * from './event-logging';
export * from './utils';
export * from './cache-driver';
export * from './container';
export * from './common-storage';
export * from './dto';
export * from './search-builder';
export * from './api-response';
export * from './model-context-factory';
export * from './web';
export * from './translation';
export * from './config';

The other compiled files seems to be valid.

Input code

No response

Config

{
    "$schema": "https://json.schemastore.org/swcrc",
    "jsc": {
        "parser": {
            "syntax": "typescript",
            "tsx": false,
            "dts": true,
            "decorators": true,
            "dynamicImport": true
        },
        "transform": {
            "legacyDecorator": true,
            "decoratorMetadata": true
        },
        "target": "es2020",
        "loose": false,
        "externalHelpers": false        
    },
    "test": ".+\\.ts$",
    "module": {
        "type": "commonjs"
    },
    "sourceMaps": true,
    "exclude": [".+\\.spec\\.ts$", ".+\\.d\\.ts$"],
    "minify": false
}

Playground link

No response

Expected behavior

Valid javascript file.

Actual behavior

A broken javascript file.

Version

1.2.242

Additional context

No response

isRyven avatar Aug 26 '22 12:08 isRyven