4

I've developed a sample stencil component to use in my existing project and it has all dependencies loaded through require js. I'm unable to import to existing project.

I've tried different configurations with module value amd, commonjs, and with target es3, es5 in stencil project's tsconfig.json, but none of them seemed to work.

After stencil build, the dist folder structure is as follows:

+ cjs
+ collection
+ esm
+ fonts
+ icons
+ index.js
+ loader
+ types
+ my-component.json
+ my-component
   - fvhzbl6z.entry.js
   - fvhzbl6z.es5.entry.js
   - fvhzbl6z.sc.entry.js
   - fvhzbl6zsc.es5.entry.js
   - my-component.abuimksq.js
   - my-component.u8wgqi9a.js
+ my-component.js         /* I'm trying to import this file */

I've tried copying the my-component folder and my-component.js to a separate folder and referenced my-component.js in a sample html file and it worked. But importing this to existing project is throwing errors.

require([
    'jquery',
    'lib/bluebird',
    'lib/mycomponent/my-component'
],
function (
    $,
    Promise,
    MyComponent
) {
    'use strict';

    /* some stuff here */

}

I'm getting the following error:

Running "requirejs:dist" (requirejs) task Error: Parse error using esprima for file: /Users/sudouser/Downloads/jsproject/dist/tmp/js/lib/stencilcomponent/my-component/fvhzbl6z.entry.js Error: Line 1: Unexpected token In module tree: app

San
  • 41
  • 2

0 Answers0