simple-keyboard-layouts icon indicating copy to clipboard operation
simple-keyboard-layouts copied to clipboard

Add "type": "module" to package.json

Open slangreck opened this issue 1 year ago • 1 comments

Description

This enables dynamic imports in a node context.

Without the "type": "module" declaration, nodejs tries to import this package as a CommonJS module when using the dynamic import(), resulting in the error "Unexpected token 'export'".

Fixes #2303

Checks

slangreck avatar Jul 02 '24 06:07 slangreck

:wave: Hello @slangreck! Please make sure to review the Contributing Guidelines to ensure your PR is compliant. Thank you!

github-actions[bot] avatar Jul 02 '24 06:07 github-actions[bot]

@hodgef Any chance this is going to be merged?

slangreck avatar Jul 04 '24 09:07 slangreck

Thanks guys, will check this out later tonight. Need to make sure it won't cause regressions for people bundling with Webpack

hodgef avatar Jul 04 '24 18:07 hodgef

Yeah as I suspected the build has failed. Maybe I can edit the bundling config (target) for the layouts instead of adding "type": "module". Will look into it tonight.

[webpack-cli] Failed to load '/home/runner/work/simple-keyboard-layouts/simple-keyboard-layouts/webpack.config.js' config
[webpack-cli] ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/home/runner/work/simple-keyboard-layouts/simple-keyboard-layouts/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.

hodgef avatar Jul 04 '24 18:07 hodgef

Hi all, I've added the commonjs layouts in version 3.4.0 https://github.com/simple-keyboard/simple-keyboard-layouts/tree/master/build/commonjs/layouts

Regards, Francisco Hodge

hodgef avatar Jul 05 '24 06:07 hodgef