question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose mdc-ripple's util.js for ES5

See original GitHub issue

I’m implementing custom MDCRippleFoundation adapter. As you mentioned in document, supportsCssVariables function in util.js would be useful to implement browserSupportsCssVars() => boolean. But, @material/ripple/dist/mdc.ripple does not exposes the utils module. So I cannot use the module without transpiler configured for MDC.

/*
 * In `some_library/src/foo.js`
 * Will be transpiled to ES5 code in `some_library/lib/foo.js`
 */
import {supportsCssVariables} from '@material/ripple/util';

...

If i use transpiler to use that module, users of some_library also have to use same transpiler. But It does not seem to be good constraints.

/* In application that does not use any transpiler  */

// Raises syntax error when importing `@material/ripple/util`
var RippleWrapper = require('some_library/lib/foo.js'); 

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
traviskaufmancommented, Feb 13, 2017

@Hardtack fair point. I can see the value in exposing the ripple’s util module via index.js. However, as a general rule we’ll probably only expose util-like modules on a case-by-case basis.

We don’t want to add too much to a public API right off the bat, only to change/remove something thus causing a breaking change.

1reaction
codesukicommented, Feb 8, 2017

I also had that problem.

Anyhow for now you can circumvent it by doing the following:

rippleFoundation = new MDCRippleFoundation(Object.assign(MDCRipple.createAdapter(this), {
// your funcs
}

This will give you a default foundation that already uses supportsCssVariables so you don’t have to implement it yourself.

Read more comments on GitHub >

github_iconTop Results From Across the Web

es5-util - npm
ES5 Utilities. A set of lightweight ES5 Utility functions can be either used in the browser or in Node.js. Heavily inspired by Locutus ......
Read more >
ES5 to ESNext — here's every feature added to JavaScript ...
Creating a promise. The Promise API exposes a Promise constructor, which you initialize using new Promise() : let done = ...
Read more >
Understand the different javascript modules formats
utils.js // we create a function function add(r){ return r + r; } // export (expose) add to other modules exports.add = add;...
Read more >
JavaScript ES5 - W3Schools
ECMAScript 2009, also known as ES5, was the first major revision to JavaScript. This chapter describes the most important features of ES5.
Read more >
Build a JavaScript Util Library for NPM with ES6 Modules and ...
Goals. Have one code source that transpiles into both ES6 and CommonJS (ES5); Tree-shakable for ES6; Implement unit testing with Jest; Auto-generate the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found