vidom icon indicating copy to clipboard operation
vidom copied to clipboard

starter kit

Open LexRiver opened this issue 5 years ago • 6 comments
trafficstars

Hello, I have some strange errors with the recent versions when trying to import component from another file, like

Uncaught TypeError: vidom: Unexpected type of element is passed to the elements factory.
    at createElement$1 (vidom.js:3124)

I know it is somehow related to my typescript settings. Can you please provide the very minimal project that works for you. I'm looking for proper settings for

  • tsconfig.json
  • webpack.config.json
  • .babelrc
  • package.json

I think that it would be useful for other users also. react has create-react-app to get started but vidom is missing it.

LexRiver avatar Dec 23 '19 17:12 LexRiver

Hi, @LexRiver! Could you investigate after which version it appears? Probably it's a bug.

dfilatov avatar Dec 25 '19 15:12 dfilatov

No, seems like it's some error in my webpack config. Because I can import .jsx files without any error.

Now I've switched to rollup and it works for me.

LexRiver avatar Dec 25 '19 18:12 LexRiver

Here's a part of my webpack config for processing tsx files:

{
    test: /\.tsx$/,
    use: [
        {
            loader: 'babel-loader',
            options: {
                plugins: [['babel-plugin-vidom-jsx', { autoRequire: false }]]
            }
        },          
        {
            loader: 'ts-loader',
            options: {
                transpileOnly: true,
                compilerOptions: {
                    sourceMap: true,
                    importHelpers: true,
                    jsx: 'preserve'
                }
            }
        }
    ]
}

dfilatov avatar Dec 25 '19 19:12 dfilatov

yes, it seems to work now, but I have a runtime error Uncaught ReferenceError: vidom is not defined unless I add a script reference in my html: <script src="https://unpkg.com/[email protected]/dist/vidom.js"></script> is it the way it should be?

LexRiver avatar Dec 26 '19 06:12 LexRiver

No, it isn't. You need to import vidom in tsx files.

// MyComponent.tsx

import * as vidom from 'vidom';

class MyComponent extends vidom.Component {
    onRender(): vidom.Node {
        return (
            <div>content</div>
        );
    }
}

dfilatov avatar Dec 26 '19 06:12 dfilatov

vidom-test-webpack.zip Here I'm trying to create minimal possible project, can you please check?

LexRiver avatar Dec 26 '19 08:12 LexRiver