olifolkerd / tabulator

Interactive Tables and Data Grids for JavaScript
http://tabulator.info
MIT License
6.71k stars 818 forks source link

Not able to Build own modules #4395

Closed kaashok closed 8 months ago

kaashok commented 8 months ago

Describe the bug When extend the module to build own module, I am getting error "Class extends value undefined is not a constructor or null"

Tabulator Info

Working Example typescript-project-tabulator.zip I have created a simple typescript project using AMD Module (as per my project settings) and attached. To setup the project run following commands

open the index.html file from dist folder to view output.

To Reproduce A step by step guide to recreate the issue in your code:

  1. open the index.html file from dist folder to view output
  2. Goto to Developer tool, you can see the error in console tab "Class extends value undefined is not a constructor or null"

Expected behavior Build a own modules in my project enviroment.

Screenshots image

Desktop (please complete the following information):

Additional context I have already create an issue regrading this, but the solution suggested by @olifolkerd is not working old issue URL: https://github.com/olifolkerd/tabulator/issues/4379

olifolkerd commented 8 months ago

I'm afraid I cant replicate your issue, it works fine when I try it.

I'm afraid for security reasons I won't download zip files from here.

It would suggest there is something with your import as the undefined is showing that the module class is not importing

kaashok commented 8 months ago

I have created a Github repo with my code, Please clone it and check the import issue.

Github Repo: Repo

olifolkerd commented 8 months ago

@kaashok Im afraid im not sure what to tell you there, it seems like there must be an issue with your build setup.

It works fine for me, and given this is the primary method of importing Tabulator into most peoples projects, if there was a break on the import functionality i would expect 100's of issue tickets to appear on this subject, or at the very least a great many comments or votes on the issue here, which just hasn't happened.

While i understand this is not the answer you were hoping for, Im afraid i cant offer a personal debugging services for peoples environments. You could try messaging on the discord server and see if anyone has any advice for you there.

Cheers

Oli :)

rathboma commented 5 months ago

@olifolkerd I've also just hit this trying to build Beekeeper using esbuild.

olifolkerd commented 5 months ago

@rathboma do you have an example of which classes you are importing that are causing the error?

Cheers

Oli :)

rathboma commented 5 months ago

Hey! We figured out the error. When using esbuild with a node target for an electron process it imports the wrong version of tabulator (or treats it wrong in some way).. Here's an esbuild plugin we wrote to fix it:


const tabulatorPlugin = {
  name: 'tabulator-tables resolver',
  setup(build) {
    build.onResolve({ filter: /^tabulator-tables$/ }, async (args) => {
      const result = await build.resolve('../../node_modules/tabulator-tables/dist/js/tabulator_esm.js', {
        kind: 'import-statement',
        resolveDir: path.dirname(args.path),
      })

      if (result.errors.length > 0) {
        return { errors: result.errors }
      }

      return {
        path: result.path
      }
    });
  },
}
mquigley commented 3 months ago

@olifolkerd As @rathboma mentioned, there is definitely a problem with importing the module into an electron node app, as of 6.2.2. The import return value of TabulatorFull is undefined.

import { TabulatorFull } from 'tabulator-tables';