Skip to content

dev-server-esbuild Side Effect Imports #1477

Open
@Marshal27

Description

@Marshal27

I have an Open-WC generated typescript monorepo with Lerna on top; I am using the esbuild plugin for the dev server per the recommendation in the documentation.

I am struggling to import the side effect from an NPM package dev dependency using the esbuild plugin.

esbuild settings

 plugins: [
    esbuildPlugin({ 
      ts: true, 
      json: true,
      target: 'auto' })
  ],
// this import works, adds .js to the end of index in the url on the network call
// this imports the exported class and works well.
import '@npm-alias/index';

// does not work, no .js extension is added on network call
import '@npm-alias/index/dist/sideEffect';

// adding .js to the end explicitly, will add .ts extension on the network call
// this generates a 404 because there is no .ts file at this level in the node_modules
// adding .ts incorrectly I believe
import '@npm-alias/index/dist/sideEffect.js';

// below works and adds the .js extension correctly
// but this is not a viable import once the package has been published
import '../../../node_modules/@npm-alias/index/dist/sideEffect';

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions