How should we support language features between projects? #433
Replies: 17 comments
-
EDIT: nope! Doesn't qualify, as we're talking about langauge features here, not syntax. Can we conditionally polyfill different features for different builds? However I do like Option 3. This solves the problem for all dependencies, not just
|
Beta Was this translation helpful? Give feedback.
-
would we be safe to leave @sindresorhus makes the point that babel caches well, so it may be that the hit is only taken when you have a cold cache.
would we end up needing to maintain a set of standards that way? it wouldn't solve the stray esnext npm module problem, but is it something that would be useful nonetheless?
one thing that i wondered about is communicating and enforcing the requirement (of option 3). it's not widespread practice, even if not unprecedented, and generally it's been safe so far to not worry about |
Beta Was this translation helpful? Give feedback.
-
Running
|
Beta Was this translation helpful? Give feedback.
-
ha ha! @SiAdcock that discussion in source runs a very similar tack :) |
Beta Was this translation helpful? Give feedback.
-
I think we're starting to see the value of discussing things on GitHub issues and discussion boards more these days - if we'd had that discussion ^ in person or on chat it would have been lost. |
Beta Was this translation helpful? Give feedback.
-
...valuable side effect of working remotely – you're always working remotely from future developers/you |
Beta Was this translation helpful? Give feedback.
-
if there is some appetite for this, should it be our first addition to the recommendations? any thoughts how could we go about making sure everyone who needed to know about it does? and make sure people are prepared for it? |
Beta Was this translation helpful? Give feedback.
-
Sounds good. Where do they live? GitHub repo? Similar to the managers docs? PR in changes? |
Beta Was this translation helpful? Give feedback.
-
I think Mariot is keen for us to revive these client side recommendations |
Beta Was this translation helpful? Give feedback.
-
that is now merged. but it did throw up a new question around which module types a package should provide. how does this sound? packages can provide either or all of the following:
package is for the web (i.e. will go through a build pipeline) {
"module": "index.mjs",
} package is for node (i.e. will be used untranspiled) {
"main": "index.js",
} package is for either {
"main": "index.js",
"module": "index.mjs",
} |
Beta Was this translation helpful? Give feedback.
-
Thanks for moving forward with this @sndrs, I'm totally on board. The only part I'd question is the Therefore I wanted to raise the question whether we should peg ourselves to what is essentially a workaround to a platform-specific problem? Browsers, for example, don't require modules to have this extension. Also are there any tradeoffs in using |
Beta Was this translation helpful? Give feedback.
-
yeah agreed, i think how about this? packages can provide any/all of the following:
package is for the web (i.e. will go through a build pipeline) {
"module": "path/to/my_esm_index.js",
} package is for node (i.e. will be used untranspiled) {
"main": "path/to/my_cjs_index.js",
} package is for either {
"main": "path/to/my_cjs_index.js",
"module": "path/to/my_esm_index.js",
} |
Beta Was this translation helpful? Give feedback.
-
Why is |
Beta Was this translation helpful? Give feedback.
-
web target would be es2020, with the expectation that you would use |
Beta Was this translation helpful? Give feedback.
-
oh, so common is for node! totally misread that. |
Beta Was this translation helpful? Give feedback.
-
full on read here facebook/react#11503 (comment) from webpack author! also been looking at feel like a common package that we can use to build maybe it could pretty much just wrap here's a test of using |
Beta Was this translation helpful? Give feedback.
-
these are minutes from/the result of a discussion in the meeting...
For example
Object.fromEntries
:core-js
@3core-js
@2This means any instance of
Object.fromEntries
in a package's source code will go straight through to the browser. The only way to guarantee it will then run is if the consuming application manages polyfilling it (if necessary).Possible solutions
1.
@guardian
modules must only ship ES52. Define a guardian JS environment
An example spec might be language features that do not need polyfilling in 90% of browsers on the Guardian.
For example,
@guardian/js-env
might look like:@guardian/js-env@123
)<script src="${require('@guardian/js-env@123')}" />
)3. Stop trusting that NPM packages ship ES5
node_modules
presents a risk – you assume the published code will run in your target envOption 3 seemed the most popular, simply because it's hard to counter that we basically do not know what we install from NPM (not really). By acknowledging this, we can make our applications more resilient and solve the support question in one go.
Any thoughts on this? @SiAdcock I know you've put a lot of thought into this for
source
.Beta Was this translation helpful? Give feedback.
All reactions