Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External lib included causes duplicate TS helpers and runtime error #1080

Closed
MrAntix opened this issue Sep 10, 2018 · 5 comments
Closed

External lib included causes duplicate TS helpers and runtime error #1080

MrAntix opened this issue Sep 10, 2018 · 5 comments

Comments

@MrAntix
Copy link
Contributor

MrAntix commented Sep 10, 2018

Stencil version:

I'm submitting a:

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

Current behavior:

Rxjs gets included in built component this includes a "function __external"
TS helper var _external is also emitted and they clash causing runtime error

Expected behavior:

Steps to reproduce:

  1. yarn build the lib
  2. yarn build the components
  3. navigate to ./components/dist/esm/es5/build/my-component.js - file contains duplicates described

I made a repro repo and included the built files
https://github.com/MrAntix/stencil-ts-duplicate-helper/blob/master/components/dist/esm/es5/build/my-component.js
https://github.com/MrAntix/stencil-ts-duplicate-helper

Related code:

see image lines 1 and 36

Other information:

image

@ionitron-bot ionitron-bot bot added the triage label Sep 10, 2018
@MrAntix
Copy link
Contributor Author

MrAntix commented Sep 13, 2018

Workaround

stencil.config.ts

import { Config } from '@stencil/core';
import postprocess from 'rollup-plugin-postprocess';

export const config: Config = {
  namespace: 'muse-ui-dugout-components',
  outputTargets: [
    {
      type: 'dist'
    }
  ],
  plugins: [
    postprocess([
      [
        `function __extends\\(`,
        'function xx__extends ('
      ]
    ])
  ],
  globalScript: 'src/global'
};

this doesn't work after all

the first var __extends is not always added to the esm file

@jthoms1
Copy link
Contributor

jthoms1 commented Sep 13, 2018

@manucorporat I believe you were looking into this.

@MrAntix
Copy link
Contributor Author

MrAntix commented Sep 13, 2018

@manucorporat

If we add importHelpers: true to the transpile options for the es5 worker, the code produced works fine
But when the global script is wrapped the import ends up inside the wrapper
I did this to move it back out

e298edb

If this approach is ok, and you want me too, I can tidy test and PR a new branch based on current master.

@MrAntix
Copy link
Contributor Author

MrAntix commented Oct 12, 2018

FYI using the version 14.0.0-1 works fine, however, the code produced causes the angular compiler to fall over

see angular/angular-cli#12568

@adamdbradley
Copy link
Contributor

The original issue should be fixed with the latest build. Thanks for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants