sebastian-software/preppy

MISSING_GLOBAL_NAME when used with LitElement

Closed this issue · 1 comments

When I try to use LitElement in a project i get the following error at build time:
- No name was provided for external module 'lit-element' in output.globals – guessing 'litElement' [MISSING_GLOBAL_NAME]

This result in my web components not intializing correctly

full output:

$ preppy --watch --entry-lib=src/test.ts --entry-browser=src/test.ts --verbose
Flags: { watch: true,
  exec: false,
  sourcemap: true,
  notify: false,
  verbose: true,
  quiet: false,
  entryLib: 'src/test.ts',
  entryBrowser: 'src/test.ts',
  entryNode: null,
  entryCli: null,
  root: '/Users/florian/Dev/perso/lib',
  output: null,
  limit: null }
Entries:
- library: src/test.ts
- browser: src/test.ts
- binaries: null
Watching lib-0.0.1...
★ Added: src/test.ts [LIB] ❯ lib/index.esm.js [ESM]
★ Added: src/test.ts [LIB] ❯ lib/index.cjs.js [CJS]
★ Added: src/test.ts [LIB] ❯ lib/index.umd.min.js [UMD]
Variables: {
  "process.env.BUNDLE_NAME": "lib",
  "process.env.BUNDLE_VERSION": "0.0.1",
  "process.env.BUNDLE_TARGET": "lib"
}
Variables: {
  "process.env.BUNDLE_NAME": "lib",
  "process.env.BUNDLE_VERSION": "0.0.1",
  "process.env.BUNDLE_TARGET": "lib"
}
Variables: {
  "process.env.BUNDLE_NAME": "lib",
  "process.env.BUNDLE_VERSION": "0.0.1",
  "process.env.BUNDLE_TARGET": "lib"
}
✔ Written: lib/index.esm.js in 561ms [4.9 kB]
✔ Written: lib/index.cjs.js in 117ms [5.14 kB]
  - No name was provided for external module 'lit-element' in output.globals – guessing 'litElement' [MISSING_GLOBAL_NAME]
✔ Written: lib/index.umd.min.js in 694ms [3.74 kB]

package json:

{
    "name"           : "lib",
    "version"        : "0.0.1",
    "description"    : "my lib",
    "main"           : "lib/index.cjs.js",
    "module"         : "lib/index.esm.js",
    "unpkg"          : "lib/index.umd.min.js",
    "types"          : "lib/index.d.ts",
    "scripts"        : {},
    "author"         : "",
    "license"        : "ISC",
    "devDependencies": {
        "@babel/core"                            : "^7.6.0",
        "@babel/plugin-proposal-class-properties": "^7.5.5",
        "@babel/plugin-proposal-decorators"      : "^7.6.0",
        "@babel/plugin-transform-runtime"        : "^7.6.0",
        "@babel/preset-env"                      : "^7.6.0",
        "@babel/preset-typescript"               : "^7.6.0",
        "@babel/runtime"                         : "^7.6.0",
        "corejs"                                 : "^1.0.0",
        "es-dev-server"                          : "^1.17.2",
        "es-module-shims"                        : "^0.4.2",
        "lit-element"                            : "^2.2.1",
        "preppy"                                 : "^8.3.1",
        "typescript"                             : "^3.6.2"
    }
}

Not sure what the issue is here. Preppy do not inline external libraries by default. There is a new "deep" mode in the last release which adds this. In other cases for UMD builds (this issue in only reported while building the UMD), you somehow have to make this component available. I am not a massive user of these UMD approaches myself. If you like to improve the implementation I am happy to work together on PRs.