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

comment is not preserved even when the minification is not enabled #7842

Closed
SukkaW opened this issue Aug 21, 2023 · 2 comments · Fixed by #7853
Closed

comment is not preserved even when the minification is not enabled #7842

SukkaW opened this issue Aug 21, 2023 · 2 comments · Fixed by #7853
Assignees
Labels
Milestone

Comments

@SukkaW
Copy link
Contributor

SukkaW commented Aug 21, 2023

Describe the bug

All the comment has been stripped away even when swc minification is not enabled.

Input code

/**
 * Copyright (c) 2013-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

'use strict';
function emptyFunction() {}
function emptyFunctionWithReset() {}
emptyFunctionWithReset.resetWarningCache = emptyFunction;

module.exports = function() {
  function shim(props, propName, componentName, location, propFullName, secret) {
    var err = new Error(
      'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
      'Use PropTypes.checkPropTypes() to call them. ' +
      'Read more at http://fb.me/use-check-prop-types'
    );
    err.name = 'Invariant Violation';
    throw err;
  };
  shim.isRequired = shim;
  function getShim() {
    return shim;
  };
  // Important!
  // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
  var ReactPropTypes = {
    array: shim,
    bigint: shim,
    bool: shim,
    func: shim,
    number: shim,
    object: shim,
    string: shim,
    symbol: shim,

    any: shim,
    arrayOf: getShim,
    element: shim,
    elementType: shim,
    instanceOf: getShim,
    node: shim,
    objectOf: getShim,
    oneOf: getShim,
    oneOfType: getShim,
    shape: getShim,
    exact: getShim,

    checkPropTypes: emptyFunctionWithReset,
    resetWarningCache: emptyFunction
  };

  ReactPropTypes.PropTypes = ReactPropTypes;

  return ReactPropTypes;
};

Config

{
  "jsc": {
    "parser": {
      "syntax": "ecmascript",
      "jsx": false
    },
    "target": "es2022",
    "minify": {
      "mangle": false,
      "compress": false
    }
  },
  "minify": false,
  "isModule": true,
  "module": {
    "type": "commonjs"
  }
}

Playground link

https://play.swc.rs/?version=1.3.78&code=H4sIAAAAAAAAA3VUTW%2FbMAy9%2B1dwJ6ddYu%2FjlqCnoAWCbd3QZus1skzHam3Jk%2BS2xtD%2FPlLOh920Fwt8pB7JR1rp%2BXkE57A0TWfVtvQwkWfw5dPnr7PGokPtp3AlJGbGPExhpWVC0XxhXSoHzrRWIkiTI5BZKYnaYQ6tztGCLxF%2BrNZ7GApDOCjNDqb4vlpeXt9eQqEq3MFgjfGQK4vSG9uBKQg9JvIWkQtIoyhuidF5q6SPF1HRaumV0YB147urnTU5g38v7%2FjulC9vqEHfB73tS1gCfyesVnq7FJIKvBjTLKKoNnlbYYLPjbHeUUAxSB%2FBwQRXqnrSWNO4KfBxLWqcknh1YzQJ3ZuVkYKj%2B5Crtqp63KG06HtGgEdhAa2lZBqf4NJaYyfBARAvRVVRufCL7q%2B7Bh1FVyoXJKjbSVt1PC5NUru24bJpZlkXBrDhtDPP9zbQCPkgtphADB%2F39L9J9wN1QpLIh4NJHXsDkgpgrnp07wZFDrWxCMJD6X0zT9MiS2pMaZKzwDM75o7DtbNFOKjTRJMK1G680tS7EtrDH2WqIFXcR%2FnSmieOZfOFPyx4otwN%2Fm2p7ZyuM7IYzmSL%2FpbHsheWNG6tPsQFmjSFVc0qUdYPvf0Nsek3s1LO8%2FK6Tkt4osXhueVtz%2F6I1vFJ%2Fk2SFiIsNW8Xq7XklikguXcbWuowUxJJ%2BuPgLnZVCWtFNw9VTQOQqa3SfoQYUw1t7nBo67bO0A4Rk93TKgwR%2Fp30doR0dXbk7WvRo0pCaT%2BL%2BV7JHsUKaxwXuIO4sSGstCNdJZ5QaHpUTss9CaNf522sTzTCXSlOMHwWLMIBC%2BB4q%2BfvvBzT3ca8eiJehfdbRN%2FxbJPhlMeuEL1bxNceovoPuXbVSbIFAAA%3D&config=H4sIAAAAAAAAA1WPQQrDIBBF955CZt1Fcdk79BBiTVAyKo6BSsjdq0Ztu%2FO%2Fz38yB%2BMcLCl48KM8Swgyko4zF0LZJfkuBLRCSSqakOA2Wku1WuRGuqHzaiDJuOrUViTuQvQFoHFmyb9%2BlG7d9JBMsfIYoib6t7P%2Bw9czV2Do6V97U6W4XwwH6eelHGqqdvTOElQhOz8jm7S4CAEAAA%3D%3D

Expected behavior

The comment should be left as it is unless the minification is enabled.

Actual behavior

No response

Version

1.3.78

Additional context

No response

@SukkaW SukkaW added the C-bug label Aug 21, 2023
@kdy1
Copy link
Member

kdy1 commented Aug 21, 2023

Seems like this is a problem of the default config.

https://play.swc.rs/?version=1.3.78&code=H4sIAAAAAAAAA3VUTW%2FbMAy9%2B1dwJ6ddYu%2FjlqCnoAWCbd3QZus1skzHam3Jk%2BS2xtD%2FPlLOh920Fwt8pB7JR1rp%2BXkE57A0TWfVtvQwkWfw5dPnr7PGokPtp3AlJGbGPExhpWVC0XxhXSoHzrRWIkiTI5BZKYnaYQ6tztGCLxF%2BrNZ7GApDOCjNDqb4vlpeXt9eQqEq3MFgjfGQK4vSG9uBKQg9JvIWkQtIoyhuidF5q6SPF1HRaumV0YB147urnTU5g38v7%2FjulC9vqEHfB73tS1gCfyesVnq7FJIKvBjTLKKoNnlbYYLPjbHeUUAxSB%2FBwQRXqnrSWNO4KfBxLWqcknh1YzQJ3ZuVkYKj%2B5Crtqp63KG06HtGgEdhAa2lZBqf4NJaYyfBARAvRVVRufCL7q%2B7Bh1FVyoXJKjbSVt1PC5NUru24bJpZlkXBrDhtDPP9zbQCPkgtphADB%2F39L9J9wN1QpLIh4NJHXsDkgpgrnp07wZFDrWxCMJD6X0zT9MiS2pMaZKzwDM75o7DtbNFOKjTRJMK1G680tS7EtrDH2WqIFXcR%2FnSmieOZfOFPyx4otwN%2Fm2p7ZyuM7IYzmSL%2FpbHsheWNG6tPsQFmjSFVc0qUdYPvf0Nsek3s1LO8%2FK6Tkt4osXhueVtz%2F6I1vFJ%2Fk2SFiIsNW8Xq7XklikguXcbWuowUxJJ%2BuPgLnZVCWtFNw9VTQOQqa3SfoQYUw1t7nBo67bO0A4Rk93TKgwR%2Fp30doR0dXbk7WvRo0pCaT%2BL%2BV7JHsUKaxwXuIO4sSGstCNdJZ5QaHpUTss9CaNf522sTzTCXSlOMHwWLMIBC%2BB4q%2BfvvBzT3ca8eiJehfdbRN%2FxbJPhlMeuEL1bxNceovoPuXbVSbIFAAA%3D&config=H4sIAAAAAAAAAz2OSw7DIAwF95wCed1FxLJ3yCEQIRUofIQdqSjK3WsIdOc3z2P5ElKCRwNvefHIIeuCtvwzE6yR9JcJWBM0muIywWu2Hlu16wNtR%2FfTAOnysdQtVItSwxBjA4KLbq9T7cjhmrbzsAypnA8Lk4z3qOaWwKQQUvQI7aC4f0AwqcHIAAAA

{
  "jsc": {
    "parser": {
      "syntax": "ecmascript",
      "jsx": false
    },
    "target": "es2022",
    
  },
  "minify": false,
  "isModule": true,
  "module": {
    "type": "commonjs"
  }
}

will preserve the comments

@kdy1 kdy1 added this to the Planned milestone Aug 21, 2023
@kdy1 kdy1 self-assigned this Aug 21, 2023
kdy1 added a commit that referenced this issue Aug 24, 2023
@kdy1 kdy1 modified the milestones: Planned, v1.3.79 Aug 25, 2023
@swc-bot
Copy link
Collaborator

swc-bot commented Sep 24, 2023

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Sep 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants