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 'moduleBlocks' isn't currently enabled #7

Open
Paul-WFUK opened this issue Sep 21, 2021 · 2 comments

Comments

@Paul-WFUK
Copy link

Paul-WFUK commented Sep 21, 2021

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.

@mcaskill
Copy link

@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.

@Paul-WFUK
Copy link
Author

@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.

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

No branches or pull requests

2 participants