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

Support for the experimental syntax 'classProperties' isn't currently enabled #303

Open
bennypowers opened this issue Jul 14, 2021 · 5 comments · May be fixed by #304
Open

Support for the experimental syntax 'classProperties' isn't currently enabled #303

bennypowers opened this issue Jul 14, 2021 · 5 comments · May be fixed by #304

Comments

@bennypowers
Copy link

Compare

https://unpkg.com/[email protected]/lib/create-effect.js?module

import { Hook, hook } from "./hook.js?module";
function createEffect(setEffects) {
  return hook(class extends Hook {
    constructor(id, state, ignored1, ignored2) {
      super(id, state);
      setEffects(state, this);
    }
    update(callback, values) {
      this.callback = callback;
      this.values = values;
    }
    call() {
      if (!this.values || this.hasChanged()) {
        this.run();
      }
      this.lastValues = this.values;
    }
    run() {
      this.teardown();
      this._teardown = this.callback.call(this.state);
    }
    teardown() {
      if (typeof this._teardown === 'function') {
        this._teardown();
      }
    }
    hasChanged() {
      return !this.lastValues || this.values.some((value, i) => this.lastValues[i] !== value);
    }});

}
export { createEffect };

with

https://unpkg.com/[email protected]/lib/create-effect.js?module

Cannot generate module for [email protected]/lib/create-effect.js

SyntaxError: unknown: Support for the experimental syntax 'classProperties' isn't currently enabled (4:17):

  2 | function createEffect(setEffects) {
  3 |     return hook(class extends Hook {
> 4 |         callback;
    |                 ^
  5 |         lastValues;
  6 |         values;
  7 |         _teardown;

Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the 'plugins' section of your Babel config to enable transformation.

undefined

Ostensibly some babelrc work is needed?

bennypowers added a commit to bennypowers/unpkg that referenced this issue Jul 14, 2021
@bennypowers bennypowers linked a pull request Jul 14, 2021 that will close this issue
@IgorNovozhilov
Copy link

I get a similar problem with private class fields:
SyntaxError: unknown: Unexpected character '#'

@bennypowers You can also add to PR:
https://www.npmjs.com/package/@babel/plugin-proposal-private-methods

and here the dependencies for plugin are not specified:

"@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.13",

@bennypowers
Copy link
Author

That plugin is included in babel preset-env

@IgorNovozhilov
Copy link

That plugin is included in babel preset-env

Here's an example, it doesn't work
https://unpkg.com/@notml/[email protected]/lib/style.js?module

@Eyal-Shalev
Copy link

@bennypowers, I'm having the same issue as @IgorNovozhilov

@pluma4345
Copy link

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

Successfully merging a pull request may close this issue.

4 participants