modularorg/modularjs

Support for the experimental syntax 'moduleBlocks' isn't currently enabled

Paul-WFUK opened this issue · 2 comments

I've been using modularjs for a while now but I'm starting to get the error as per the title but can't seem to find a solution online. it happens when using the following code:

  1 | import { module } from 'modujs';
  2 |
> 3 | export default class extends module {
    |                              ^
  4 |     constructor(m) {
  5 |         super(m);
  6 |

I'm using Laravel-mix 6.0.6 for front end development and compiling. I have rolled this back to 5 where it has previously been okay but still received the above error.

I was wondering if someone could help or point me in the right direction.

@Paul-WFUK This appears to be an issue with Babel. It's interpreting the module as a keyword for the "module blocks" proposal:

let m = module { export let y = 1; };

Lately, I have noticed IDEs are highlighting that word as if a special keyword.

Try renaming the module:

import { module as BaseModule } from 'modujs';

export default class extends BaseModule {

@ABXlink What are your thoughts?

Should the class be renamed for future-proofing?

export { default as BaseModule } from './module';

Maybe even rename the class and the data attributes to component? It's a common nomenclature in other frameworks.

export { default as Component } from './module';

Alternatively, allow one to import from the module file directly:

import BaseModule from 'modujs/module';

Which requires updating the package.json.

@mcaskill many thanks for your reply. and the above advice.

I did eventually work out it had something to do with Babel and the pending proposal so just rolled back the Babel version for this particular project. Although what's suggested above is much simpler workaround.