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

minifier: odd auto-definition in 1.2.74 #2011

Closed
kapouer opened this issue Aug 4, 2021 · 5 comments · Fixed by #2052
Closed

minifier: odd auto-definition in 1.2.74 #2011

kapouer opened this issue Aug 4, 2021 · 5 comments · Fixed by #2052
Assignees
Labels
Milestone

Comments

@kapouer
Copy link

kapouer commented Aug 4, 2021

This one is harder to isolate for now.

The result i get is:

var Ua
S.exports = (_defineProperty(Ua = (_createClass(Ua, [{
				key: "init",

Uncaught TypeError: Cannot read property 'prototype' of undefined
at _createClass (site.min.js:2)

I attach the source (bundled by another tool). It's messy...
Likely comes from that part:

module.exports = class BlockView {

however i tried to isolate it and couldn't reproduce.

bundle.js.gz

@kapouer kapouer added the C-bug label Aug 4, 2021
@kdy1 kdy1 modified the milestones: v1.2.75, v1.2.76, v1.2.77 Aug 5, 2021
@kdy1
Copy link
Member

kdy1 commented Aug 10, 2021

Did you use transform? What was your .swcrc?
_createClass is injected by swc or babel, so I couldn't reproduce it.

@kdy1 kdy1 modified the milestones: v1.2.76, v1.2.77 Aug 10, 2021
@kapouer
Copy link
Author

kapouer commented Aug 10, 2021

{
	"sourceMaps": false,
	"jsc": {
		"loose": true,
		"parser": {
			"syntax": "ecmascript",
			"classPrivateProperty": true
		},
		"target": "es3",
		"minify": {
			"compress": true,
			"mangle": true
		}
	},
	"minify": true
}

i'll check with 1.2.76 if this happens again, and close or report further info accordingly.

@kapouer
Copy link
Author

kapouer commented Aug 10, 2021

Nailed it !
Using swc 1.2.76

class ClassA {}

module.exports = class ClassB {
 static MyA = ClassA;

 it() {
  this.bb = new ClassB.MyA();
 }
}

and .swcrc as the one above.

@kdy1
Copy link
Member

kdy1 commented Aug 10, 2021

Thank you a lot! Reducing a test case is the most hard part :)

kdy1 added a commit to kdy1/swc that referenced this issue Aug 11, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Aug 11, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Aug 11, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Aug 11, 2021
@kdy1 kdy1 self-assigned this Aug 11, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Aug 11, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Aug 11, 2021
kdy1 added a commit that referenced this issue Aug 11, 2021
swc_ecma_minifier:
 - Test mangler using execution test suite.
 - `mangler`: Preserve `arguments`.
 - `mangler`: Handle shorthand. (#2051)
 - `mangler`: Handle object pattern properties.
 - `precompress`: Don't drop function declarations if the variable with same name is in different scope. (#2011)
@swc-bot
Copy link
Collaborator

swc-bot commented Oct 22, 2022

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 Oct 22, 2022
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