mjackson / unpkg

The CDN for everything on npm
https://unpkg.com
Other
2.98k stars 302 forks source link

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

Open bennypowers opened 3 years ago

bennypowers commented 3 years ago

Compare

https://unpkg.com/haunted@4.8.1/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/haunted@4.8.2/lib/create-effect.js?module

Cannot generate module for haunted@4.8.2/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?

IgorNovozhilov commented 3 years ago

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: https://github.com/mjackson/unpkg/blob/a7ebffaa4928e95e14dc467979860779bcdcd8a7/package.json#L17

bennypowers commented 3 years ago

That plugin is included in babel preset-env

IgorNovozhilov commented 3 years ago

That plugin is included in babel preset-env

Here's an example, it doesn't work https://unpkg.com/@notml/core@0.1.0-pre.7/lib/style.js?module

Eyal-Shalev commented 3 years ago

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

pluma4345 commented 5 months ago

Same here: https://unpkg.com/arangojs@9.0.0-preview.1/esm/database.js?module