Skip to content

export DOM shim via exports map (and standardize export map entries) #230

@thescientist13

Description

@thescientist13

Motivation

Currently, if wanting to import the DOM shim ad-hoc, it's not possible because it is not in the exports map
Image

And if trying to run it through a bundler, it will of course not resolve

[plugin node-resolve] Could not resolve import "wc-compiler/dom-shim.js" in /Users/owenbuckley/Workspace/project-evergreen/playground.wcc.dev/src/scripts/repl.ts using exports defined in /Users/owenbuckley/Workspace/project-evergreen/playground.wcc.dev/node_modules/wc-compiler/package.json.

Technical Design

It might also be useful to standardize the exports map entries to remove references to the src/ folder, and optionally drop the .js file extension (as some do, and some don't)

THIS WOULD BE A BREAKING CHANGE

"exports": {
  ".": {
    "types": "./src/index.d.ts",
    "import": "./src/wcc.js"
  },
  "./register": "./src/register.js",
  "./dom-shim": "./src/dom-shim.js",
  "./jsx-loader": "./src/jsx-loader.js",
  "./jsx-runtime": "./src/jsx-runtime.ts"
},

Additional Context

This may be useful for standing up the new REPL, or other ad-hoc usages of WCC
https://github.com/ProjectEvergreen/playground.wcc.dev/pull/4/changes#diff-ac8ae2dd3b406c61d10fe7646195c4255dfefea921fdcf8ffacf606f85556a4dR4

Metadata

Metadata

Projects

Status

✅ Done

Relationships

None yet

Development

No branches or pull requests

Issue actions