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

Update 3.5.1 -> 3.5.2 breaks meteor package with customized uniforms-unstyled #1001

Closed
JanMP opened this issue Aug 18, 2021 · 10 comments · Fixed by #1028
Closed

Update 3.5.1 -> 3.5.2 breaks meteor package with customized uniforms-unstyled #1001

JanMP opened this issue Aug 18, 2021 · 10 comments · Fixed by #1028
Assignees
Labels
Type: Bug Bug reports and their fixes
Milestone

Comments

@JanMP
Copy link

JanMP commented Aug 18, 2021

After updating I get the same error as #703

Uncaught TypeError: Class constructor _ cannot be invoked without 'new'
    at new AutoForm
    at new _ (AutoForm.tsx:6)

I only changed some of the fields. AutoForm is untouched.
Renaming _ to something else did not help.

Repro is here: https://github.com/JanMP/repro-uniforms-3.5.2-error (see two commits for changes that lead to problem)

@radekmie radekmie self-assigned this Aug 18, 2021
@radekmie radekmie added the Type: Question Questions and other discussions label Aug 18, 2021
@radekmie radekmie added this to Needs triage in Open Source (migrated) via automation Aug 18, 2021
@radekmie radekmie moved this from Needs triage to In progress in Open Source (migrated) Aug 18, 2021
@radekmie
Copy link
Contributor

Hi @JanMP. Please do check whether the newest version works. I guess this problem got fixed in v3.5.4 (actually v3.5.3, but it's an incorrect release).

@JanMP
Copy link
Author

JanMP commented Aug 18, 2021

No, it doesn't. I updated from 3.5.1. to 3.5.5. Things broke and then I went back and forth and narrowed it down to starting at 3.5.2

@radekmie
Copy link
Contributor

OK, it makes sense. We'll look into that soon.

@radekmie radekmie assigned kestarumper and unassigned radekmie Aug 25, 2021
@radekmie radekmie added Type: Bug Bug reports and their fixes and removed Type: Question Questions and other discussions labels Aug 25, 2021
@radekmie radekmie added this to the v3.5 milestone Aug 25, 2021
@kestarumper
Copy link
Member

Hi @JanMP, thanks for pointing this out as it appears that we've introduced a regression. We're investigating and we'll keep you posted once we find something.

@radekmie
Copy link
Contributor

I thought about it a little bit more and I'd say that we have to decide, whether we publish actual ES6 classes or not. Overall, there's no point in es5/es6 builds and we should rather have a cjs/esm separation, just like other packages. The only question is what EcmaScript standard are we going to use for the build.

ES6 seems a valid choice, as it's already supported by all supported platforms. And if someone's bundler is down-leveling classes, then it's up to the user to downlevel them in our bundle as well.

What do you think?


@kestarumper In order to make sure that it'll work without problems in all major platforms, i.e., CRA, Gatsby, Meteor, please od check whether the es6 build works in all of them. If it does, then I think we have our winner here.

@macrozone
Copy link
Contributor

just to add some information: 3.5.2 also breaks in nextjs (tried actually with 3.5.5). 3.5.1 works though

@radekmie
Copy link
Contributor

@kestarumper Could you post your status here? I know you've checked something already.

@radekmie radekmie modified the milestones: v3.5, v3.6 Sep 13, 2021
@kestarumper
Copy link
Member

kestarumper commented Sep 15, 2021

A few facts from my side.

uniforms 3.5.5

create-react-app

  • works fine
  • by default loads uniforms/esm
tsconfig
{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "include": [
    "src"
  ]
}

gatsby

  • works fine
  • by default loads uniforms/es5
tsconfig
{
    "compilerOptions": {
        "outDir": "./dist/",
        "sourceMap": true,
        "noImplicitAny": true,
        "module": "commonjs",
        "target": "esnext",
        "jsx": "react",
        "lib": ["dom", "es2015", "es2017"]
    },
    "include": [
        "./src/**/*"
    ]
}

Right now I'm performing further tests on what might be the issue, and I'm trying to find a common solution.

[UPDATE]

I artificially forced your reproduction to use uniforms/es6 and it works correctly.
I also checked create-react-app and gatsby if they work correctly, and I managed to make all three work (no application code changes) with the

// node_modules/uniforms/package.json
...
"main": "./es5/index.js",
"module": "./es6/index.js",
...

I'll probably also try Next.js and if it will work then I'll create a PR to set those main and module to es5 and es6 builds.

[UPDATE 2]

In the end, we created two builds targeting ES6 with CommonJS modules and ES6 modules. More on that in #1028.

@kestarumper kestarumper moved this from In progress to Review in Open Source (migrated) Sep 22, 2021
Open Source (migrated) automation moved this from Review to Closed Sep 29, 2021
@JanMP
Copy link
Author

JanMP commented Jan 3, 2022

With Meteor 2.5.2 and Uniforms 3.7.0 everything works fine in the browser, but I get the error with Cordova (output from ios, android does not work either).

2022-01-03 11:55:29.911453+0100 sdui-dev[11709:11582136] Uncaught Error: TypeError: Cannot call a class constructor without |new|:79731:http://localhost:12400/__cordova/packages/modules.js?hash=9e468c6d60c3f11da1c3669c0b0c444db669c463
2022-01-03 11:55:29.912947+0100 sdui-dev[11709:11582136] ERROR: The above error occurred in the <AutoValidatedQuickUnstyledForm> component:
    in AutoValidatedQuickUnstyledForm (created by FormTest)
    in div (created by FormTest)

@radekmie
Copy link
Contributor

Hi @JanMP, sorry for the late response. As we're not using Codova ourselves anymore, we'd need a reproduction to confirm and fix that. Please do file a new issue with a reproduction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Bug reports and their fixes
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants