9.7.5 • Published 2 months ago

@talend/module-to-cdn v9.7.5

Weekly downloads
1,399
License
MIT
Repository
github
Last release
2 months ago

@talend/module-to-cdn

Build Status NPM dependencies devdependencies

Get cdn config from npm module name

Fork

This module is fork of module-to-cdn from Thomas Sileghem.

Because unpkg is great for free usage but not for production usage we decided to made some changes to go forward.

After the following big PR on the repository and an email to the author we have got no news from the author as all other PRs. So we decided to fork.

Install

$ npm install --save @talend/module-to-cdn

Usage

const moduleToCdn = require('@talend/module-to-cdn');

moduleToCdn('react', '15.3.0');
/* => {
    name: 'react',
    var: 'React',
    url: 'https://unpkg.com/react@15.3.0/dist/react.min.js',
    version: '15.3.0',
    path: '/dist/react.min.js',
    local: '/Users/me/module-to-cdn/node_modules/react/dist/react.min.js'
}
*/

API

moduleToCdn(moduleName, version, options)

return the result Object or null (if module couldn't be find)

moduleName

Type: string

The name of the module

version

Type: string

The version of the module

options

options.env

Type: string Values: development, production Default: development

Result

  • name: name of the module
  • var: name of the global variable exposing the module
  • url: url where the module is available
  • version: the version asked for
  • path: relative path of the umd file in the distributed package
  • local: absolute path on the current system to the file

Configuration of the resolver

By default the URL resolver just resolve to unpkg. You can change that using the following API.

import moduleToCdn from '@talend/module-to-cdn';

function myResolver(...args) {
    const info = moduleToCdn(...args);
    if (process.env.NODE_ENV !== 'development') {
        return {
            ...info,
            url: `https://cdn.talend.com/${info.name}/${info.version}${info.path}`
        };
    }
    return info;
}
moduleToCdn.configure(myResolver);

Support private CDN

The module.json file is an open effort on existing opensource libs. If you want to support custom internal library you can add entries in this file using the following API:

import moduleToCdn from '@talend/module-to-cdn';

moduleToCdn.add({
    '@talend/my-private-module': {
        var: 'TalendMyPrivateModule',
        versions: {
            '>= 0.0.0' : {
                'development': '/dist/build.js',
                'production': '/dist/build.min.js',
            }
        }
    }
});

This will affect all future call to moduleToCdn;

Tests

This module do integration tests so it requests npm / unpkg for every packages on the limit of each version and also it tries to fetch the @next version to be as future proof as possible

So if you want to focus on a given module you can use the LIMIT env variable

LIMIT=";ag-grid;ag-grid-community;ag-grid-enterprise;" ava -v

Excluded modules

  • hoist-non-react-statics: the umd build contains JS errors (process.env.NODE and require) on every versions.

Contribute

To add your modules you have to

  • checkout this package on github
  • install and run the tests (it will load the cache for the tests)
  • add your module in the module.json file
  • ensure everytime the provided umd path exists and is valid.

Example of not valid umd: https://unpkg.com/browse/react-popper@1.3.7/dist/index.umd.js createContext,deepEqual dependencies are always null.

License

MIT © Thomas Sileghem

9.7.5

2 months ago

9.7.4

2 months ago

9.7.3

3 months ago

9.7.2

5 months ago

9.7.1

5 months ago

9.7.0

8 months ago

9.7.0-alpha.0

11 months ago

9.7.0-alpha.1

11 months ago

9.6.2

11 months ago

9.6.1

11 months ago

9.6.0

11 months ago

9.5.1

11 months ago

9.5.0

11 months ago

9.4.1

11 months ago

9.4.0

11 months ago

9.3.2

11 months ago

10.1.0

11 months ago

10.0.1

11 months ago

10.0.2

11 months ago

9.3.1

11 months ago

9.3.0

12 months ago

10.0.0

12 months ago

10.0.0-alpha.1

12 months ago

9.2.2

12 months ago

9.2.2-alpha.0

12 months ago

9.2.1

12 months ago

9.2.1-alpha.6

12 months ago

9.2.1-alpha.5

12 months ago

9.2.1-alpha.4

12 months ago

9.2.1-alpha.3

12 months ago

9.2.1-alpha.0

12 months ago

9.2.1-alpha.2

12 months ago

9.2.1-alpha.1

12 months ago

9.2.0

12 months ago

9.2.0-alpha.0

12 months ago

9.2.0-alpha.1

12 months ago

9.1.0

12 months ago

9.0.1

12 months ago

9.1.0-ng.0

12 months ago

7.5.1

12 months ago

9.1.0-alpha.0

12 months ago

9.0.0

12 months ago

9.0.0-jest.0

12 months ago

8.0.2

12 months ago

8.0.1-jest.0

12 months ago

8.0.1

12 months ago

8.0.0

12 months ago

7.5.1-alpha.0

12 months ago

7.5.0

1 year ago

8.0.0-jest.26

1 year ago

7.4.3

1 year ago

7.4.2

1 year ago

7.4.1

1 year ago

7.4.0

1 year ago

7.3.1

1 year ago

8.0.0-alpha.2

1 year ago

8.0.0-alpha.1

1 year ago

7.3.0

1 year ago

7.2.1

1 year ago

7.1.3

1 year ago

7.2.0

1 year ago

7.1.2

1 year ago

7.1.1

1 year ago

7.1.0

1 year ago

6.10.1

1 year ago

7.0.5

1 year ago

7.0.4

1 year ago

7.0.2-alpha.0

1 year ago

7.0.2-alpha.1

1 year ago

7.0.3

1 year ago

7.0.2

1 year ago

7.0.1

1 year ago

7.0.1-alpha.1

1 year ago

7.0.1-alpha.0

1 year ago

7.0.0

1 year ago

6.10.0

1 year ago

3.13.0

1 year ago

3.12.3

1 year ago

3.12.2

1 year ago

3.12.1

1 year ago

3.12.0

1 year ago

3.11.1

1 year ago

3.11.0

1 year ago

3.10.1

1 year ago

3.10.0

1 year ago

3.9.1

1 year ago

3.9.0

1 year ago

3.8.0

1 year ago

3.7.1

1 year ago

3.7.0

1 year ago

3.6.0

1 year ago

3.4.0

1 year ago

3.3.0

1 year ago

3.2.1

1 year ago

3.2.0

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago