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

Not webpack friendly #7

Open
theogravity opened this issue Aug 12, 2017 · 3 comments
Open

Not webpack friendly #7

theogravity opened this issue Aug 12, 2017 · 3 comments

Comments

@theogravity
Copy link

I'm using https://github.com/storybooks/storybook along with Typescript 2.4.2 - storybook uses webpack to generate its output. When using typescript-memoize, I get the following:

WARNING in ./node_modules/typescript-memoize/dist/memoize-decorator.js
3:24-31 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

I think this is due to how the export is defined within a function.

@toverux
Copy link

toverux commented Sep 4, 2017

Indeed. The export cannot be statically resolved with the current UMD build.

@darrylhodgins it would be cool to also provide a build with ES 2015 import/exports. The path can then be specified in the module key of package.json (like here). That way, tools like Webpack and Rollup will choose the ESM version, while you still support older setups with main.

Workaround 1 - import the file directly:

import { Memoize } from 'typescript-memoize/src/memoize-decorator';

Workaround 2 - set up a Webpack alias:

resolve: {
    alias: {
        // The UMD build of typescript-memoize can't be statically resolved by Webpack.
        // See https://github.com/darrylhodgins/typescript-memoize/issues/7
        'typescript-memoize$': modulesRoot('typescript-memoize/src/memoize-decorator.ts')
    }
}

@MickL
Copy link

MickL commented Mar 23, 2018

Workaround 1 gives me an error:

Module build failed: Error: node_modules/typescript-memoize/src/memoize-decorator.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://goo.gl/jB3GVv).

@toverux
Copy link

toverux commented Mar 24, 2018

Check your tsconfig configuration so that this file can be included in the compilation.

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

3 participants