Comments (14)
Hey @emcniece, thanks for your initial work. One simple fix is to use explicit userland modules instead of relying on polyfills. For example, use object-assign
and the object-keys
npm packages instead of relying on Object.keys
and Object.assign
being implemented in the runtime.
I believe those are the only functions that babel-polyfill
is actually fulfilling in this package.
from particle-api-js.
Version 6.0.1 now uses babel-runtime
instead of babel-polyfill
. If anybody is still having an issue with the transpiler or sees only one instance of babel-polyfill is allowed
please comment and I'll reopen this issue.
from particle-api-js.
Confirmed that this works within my project - thank you!
from particle-api-js.
For instance, polyfilling Promises when Node 4 and 5 have them natively.
A polyfill will not override an existing native implementation. The difference between babel-polyfill
and babel-runtime
is whether or not the global namespace is modified to support ES2015.
I can see why an app developer wouldn't want extra code that they don't use. I don't like that we get a full polyfill while only using a few of them. I want to try a couple different ways to get only specific ones we use. Would that alleviate your concerns?
from particle-api-js.
Sure. I've seen from a few libraries that want to be explicit specifying individual babel plugins in the .babelrc file instead of using a preset.
from particle-api-js.
That works for syntax transforms but not runtime dependencies.
from particle-api-js.
Right. The solutions I can think of are either tree-shaking in the build process with Rollup or Webpack 2, or switch to explicitly using each polyfill you need.
from particle-api-js.
So I just hit an issue while trying to use particle-api-js in a pre-compiled angular environment:
Uncaught Error: only one instance of babel-polyfill is allowed
I'm including the script directly in HTML because this is a restrictive node/angular plugin-esque system and I can't get NPM modules through to the front end, which is frustrating to say the least. Is this related to this issue?
from particle-api-js.
@lourd @brycekahle a penny for your thoughts :D
from particle-api-js.
Haha 😉
@brycekahle, any progress made on this? It looks like the methods that may need polyfills are limited to Object.assign
and Object.keys
.
from particle-api-js.
Unfortunately no progress. I'm pretty swamped at the moment so if you have time to put together a PR that polyfills only the necessary features that would be really helpful.
from particle-api-js.
Cool, thanks @brycekahle!
@lourd - this is a bit beyond my knowledge, but I'll try to help out. Here's a first step - it's not working, tests fail on trying to find babel-runtime
. I'll navigate this maze over the next week or two, but some tips would be greatly appreciated ;)
https://github.com/emcniece/particle-api-js/tree/babel-runtime-conversion
https://github.com/spark/particle-api-js/compare/master...emcniece:babel-runtime-conversion?expand=1
from particle-api-js.
I gave your links a shot tonight, and they don't seem to be compatible as they use require
instead of import
. I looked around for some other ES6 ObjectAssign polyfills and they all seem to use require
, which Babel fails on. (6:1 error 'require' is not defined no-undef
)
I must be missing something obvious...
from particle-api-js.
That sounds like a linter error, not an actual program error.
require
is built into Node. It's part of what's known as the CommonJS module system. import
is part of the ES6 module system, as you mentioned. The Babel configuration for this project transpiles the import
statements into require
statements. Node does not support ES6 modules natively yet (work is underway, Google '.ejs vs package.json' for some fun reading over the debates happening right now).
So you can use import
without a problem, i.e. import assign from 'object-assign'
. The linter is setup to enforce using the new syntax.
from particle-api-js.
Related Issues (20)
- Uncaught Error: only one instance of babel-polyfill is allowed HOT 1
- Create Typescript compatible version of API HOT 1
- downloadFirmwareBinary and downloadProductFirmware don't check this.prefix HOT 1
- downloadFirmwareBinary and downloadProductFirmware need tests
- listProductFirmware returns "response" instead of parsed response HOT 1
- uploadProductFirmware only tests with Buffer, and doesn't test with filename HOT 1
- Particle.CallFunction Not Working HOT 3
- loginAsClientOwner only uses default token duration
- particle-api-js ^9.1.0 not working with Svelte ^3.37.0
- 429 error is not properly converted to an object
- Unsupported engine warning, even when node + npm versions meet requirement HOT 1
- can't seem to find a place to use my oauth client id / client secret HOT 1
- addDeviceToProduct doesn't appear to reject on error? HOT 1
- Possible issue with activateSIM with products
- Version 7.1.0 not published to npm HOT 2
- How to detect by code the moment of WIFi deconnection?
- Update coveralls when new version is released
- Add tests for EventStream
- Drop Support for Node v4 HOT 1
- `EventStream` doesn't handle dropped connections HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from particle-api-js.