Stencil: Importing external lib not working in 0.5.1

Created on 15 Feb 2018  路  3Comments  路  Source: ionic-team/stencil

Stencil version:

 @stencil/[email protected]

I'm submitting a:
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://stencil-worldwide.slack.com

Current behavior:
I'm working on a leaflet component built with stencil, and everything was working fine with 0.4.3. I'm trying to upgrade to 0.5.1 and that fails at leaflet import

Expected behavior:
Leaflet import should work as before

Steps to reproduce:

Related code:
In below code @stencil/[email protected] -> L.map works
In 0.5.1 -> its undefined i.e it shows as undefined.map

import * as L from 'leaflet';
this.map = L.map('leaflet-map', 

Other information:
In console it prints [ WARN ] 'map' is not exported by 'node_modules/leaflet/dist/leaflet-src.js' after running the build with 0.5.1

Sample repo to replicate
https://github.com/harshabonthu/stencil-bug-540
npm i
npm start
Check the console -> it prints undefined, with 0.5.0-2 it prints the function map.

bug

Most helpful comment

Fortunately it looks like a simple change. With the Typescript 2.7 commonjs imports are a little simpler.

import L from 'leaflet';

I verified this against the repo you provided. Thanks for the simple usecase!

All 3 comments

Did some more testing and nailed down to this commit -> https://github.com/ionic-team/stencil/commit/256e70a8d3fff2b25ce884cbda2725630d03e7c1

Works fine until 0.5.0-2 and broke with 0.5.0-3

Fortunately it looks like a simple change. With the Typescript 2.7 commonjs imports are a little simpler.

import L from 'leaflet';

I verified this against the repo you provided. Thanks for the simple usecase!

@jthoms1 : Thanks for the tip. I believe the new way to import a module should be documented somewhere, seems lots of people are coming across that issue.

Was this page helpful?
0 / 5 - 0 ratings