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

How do I import commonjs module in typescript project? #271

Open
shanmugapriyaEK opened this issue Dec 5, 2019 · 0 comments
Open

How do I import commonjs module in typescript project? #271

shanmugapriyaEK opened this issue Dec 5, 2019 · 0 comments

Comments

@shanmugapriyaEK
Copy link

shanmugapriyaEK commented Dec 5, 2019

Thanks a lot for saving my development time.
I am using bili in my typescript player library project.

I want to import Shaka player in my typescript. Shaka player does not have types.
'https://github.com/google/shaka-player'
But I am unable to import it.

Bili config

const config: Config = {
  globals: {
    shaka: 'shaka',
  },
  resolvePlugins: {
    'shaka-player': require('./packages/XXX/node_modules/shaka-player/dist/shaka-player.compiled'),
  },
  plugins: {
    ['node-resolve']: {
      jsnext: true,
      preferBuiltins: true,
      browser: true,
    },
    typescript2: {
      cacheRoot: path.join(__dirname, '.rpt2_cache'),
      useTsconfigDeclarationDir: true,
    },
    commonjs: {
      namedExports: {
        'shaka-player': ['shaka'],
      },
    },
    terser: {
      mangle: {
        properties: {
          regex: /_$/,
          // regex: /_[a-zA-Z0-9(,)]*/,
        },
      },
    },
  },
  input: 'packages/xxx/lib/index.ts',
  env: {
    NODE_ENV: 'production',
    SDK_VERSION: JSON.stringify(require('./package.json').version),
  },
  output: {
    format: ['iife-min', 'esm-min'],
    moduleName: 'xxx',
    dir: './dist',
  },
  
};
export default config;
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

1 participant