microsoft / microsoft/reflect-metadata

Reflect-Metadata doesn't work with WebPack 3 Scope Hoisting

Open
#77 1 comment 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3.4k
Forks
190
Avg merge
13h 52m
Merged PRs (30d)
1

Description

I tried reporting this to the WebPack team and they said it is a problem with Reflect-Metadata.

I'm using Reflect-Metadata in a TypeScript project that's being built and bundled with WebPack 3. When I add the scope hoisting plugin to my WebPack config, the project no longer runs properly.

I get the following error:
Uncaught TypeError: Reflect.hasOwnMetadata is not a function
at injectable.js:7
at Object.__decorate [as a] (tslib.es6.js:48)
at Object../client/app/app.bootstrap.ts (data.service.ts:4)
at webpack_require (bootstrap 1856459e76a82a034076:54)
at webpackJsonpCallback (bootstrap 1856459e76a82a034076:25)
at app.js:1
(anonymous) @ injectable.js:7
__decorate @ tslib.es6.js:48
./client/app/app.bootstrap.ts @ data.service.ts:4
webpack_require @ bootstrap 1856459e76a82a034076:54
webpackJsonpCallback @ bootstrap 1856459e76a82a034076:25
(anonymous) @ app.js:1

Is there a way to make it work, or can this problem be fixed?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the TypeError with Webpack 3 scope hoisting and inspect the generated bundle around injectable.js and the Reflect-Metadata initialization. Compare the module path with tslib.es6.js and app.bootstrap.ts/data.service.ts; done means the project runs with scope hoisting while Reflect.hasOwnMetadata remains available.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, webpack
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.