Npm Packages within Plugins

Hello! I’ve been having a lot of fun developing JS scripts for Kintone, and I’m currently moving on to developing my first plugin from scratch through plugin-packer.

I wanted to reference some npm packages (e.g. moment, sweetalert2), but I get the following error when using ‘require’:
_"Uncaught ReferenceError: require is not defined"_

For JS customizations, I could use 'require' references with no issues, likely because I bundled first through webpack before uploading to Kintone.

But I wonder if plugin-packer acts differently (i.e. not necessarily bundling?).
My plugin works perfectly if I remove the “require” and related functions.

The Import line:

const moment = require(‘moment’);

Thank you in advance for any tips!

Update: Solution found!

Instead of plugin-packer, I was supposed to use webpack-plugin-kintone-plugin for my use case!

The currently available tutorials are

Hopefully, a full tutorial in English is on the way :slight_smile:

The Webpack section is missing in the Package Plug-in Files using plugin-packer article.