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

bug: unable to externalize modules using stencil config #3336

Closed
3 tasks done
selodev opened this issue Apr 18, 2022 · 4 comments
Closed
3 tasks done

bug: unable to externalize modules using stencil config #3336

selodev opened this issue Apr 18, 2022 · 4 comments

Comments

@selodev
Copy link

selodev commented Apr 18, 2022

Prerequisites

Stencil Version

2.15.0

Current Behavior

We are not able to externalize or share NPM modules between projects because the external option has been removed in the stenciljs config. Why would you even lock down stencil js config ? We would like that stencil.config.ts to be fully unopinionated so that developer or the consumer of stencil js can have full control over both stencil js and rollup config. We are a huge company wanting to use stencil js but not being able to extend the current stencil js config options is a huge bottleneck. We would like at least the external option in the output targets be enabled again.

Best regards,
Any feedback is greatly appreciated.

Expected Behavior

We should be able to externalize npm modules `by using external and globals options for rollup config in stencil js config.

Steps to Reproduce

export const config = {
  namespace: 'my-component',
  outputTargets: [
    {
      type: 'dist',
      esmLoaderPath: '../loader',
      external: ["moment"]
    },
    {
      type: 'dist-custom-elements',
      external: ["moment"]
    },
    {
      type: 'docs-readme',
    },
    {
      type: 'www',
      serviceWorker: null, // disable service workers
      external: ["moment"]
    },
  ],
  rollupPlugins: {
    before: [
      {
        name: 'externalize-dependency',
        resolveId(source) {
          if (source === 'moment') {
            return { id: 'moment', external: true };
          }
          return null;
        },
      },
    ]
  },
  rollupConfig: { outputOptions: { globals: { moment: 'moment' } } },
};

Code Reproduction URL

n/a

Additional Information

We are not able to externalize or share npm modules at all.

@ionitron-bot ionitron-bot bot added the triage label Apr 18, 2022
@rwaskiewicz rwaskiewicz changed the title bug: bug: unable to externalize modules using stencil config Apr 18, 2022
@rwaskiewicz
Copy link
Contributor

Hey @selodev 👋

Would #3227 address your desire to externalize dependencies? It adds the external option to the Stencil configuration file (via the rollupConfig field)

@rwaskiewicz rwaskiewicz added Awaiting Reply This PR or Issue needs a reply from the original reporter. and removed triage labels Apr 18, 2022
@selodev
Copy link
Author

selodev commented Apr 19, 2022

@rwaskiewicz yes that would be great. thank you.

@ionitron-bot ionitron-bot bot removed the Awaiting Reply This PR or Issue needs a reply from the original reporter. label Apr 19, 2022
@selodev
Copy link
Author

selodev commented Apr 19, 2022

I just want to say that Ionic Team has done a great job with Stencil JS bundling and all the rest of the features. It is just also good to be able to customize and extend existing bundling features, I can go ahead and close this bug. Please let me know.

@rwaskiewicz
Copy link
Contributor

@selodev Thanks! If you wouldn't mind, I think closing this issue would be appropriate. We have it linked to Issue 3227 now, so we have the context & details that you provided associated with the PR should we need them

Thanks again!

@selodev selodev closed this as completed Apr 19, 2022
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

2 participants