Comments (5)
The content-api.js and the content-api.min.js are not being transpiled to es5.
cjs/content-api.js
should not be transpiled to es5 as it's a node.js build.
umd/content-api.min.js
should definitely be transpiled and have polyfills bundled as that is intended as a standalone browser build for use with <script src="https://unpkg.com/@tryghost/[email protected]/umd/content-api.min.js">
. Thanks for pointing out the bug!
If you're pulling this module into a webpack build it will actually look at the module
value in package.json
and then use the lib/index.js
code which is the source code. It was my assumption that webpack would automatically transpile that code based on your app's configured targets but it appears I was too optimistic about the current state of various bundler environments π
I've updated our rollup config across our isomorphic packages so that we generate an es/{package}.js
file as the "module" build that webpack will use. This build will include transpilation back to the default browser support of @babel/preset-env
as well as inclusion of any necessary polyfills. Unfortunately this will result in larger builds but I can't see a way around that, if a module consumer really wants to shave off some bytes it will be up to them to reference the lib/*
files with appropriate transpilation in their build config.
Please try upgrading to the new 1.2.0 version and let me know how it goes π
from sdk.
Thanks @kevinansfield, it worked!
from sdk.
Import on your project import GhostContentAPI from '@tryghost/content-api';
How are you doing the import and resulting transpilation? The ES module version of the library is written with ES6 so it's expected that it will be transpiled with babel etc to work with your chosen browser/environment targets.
from sdk.
@kevinansfield Thanks for the prompt response!
Answering your question I have a react application using webpack and babel.
One other thing I realized was that on my node_modules
I have this folder:
The content-api.js
and the content-api.min.js
are not being transpiled to es5. Do you have any insights that can help me?
from sdk.
Yep, the code is not being transpiled to es5, I believe this has to do with this issue: rollup/rollup-plugin-babel#260
I solve the problem for now by adding exclude: [/node_modules\/(?!(@tryghost)\/).*/],
to my webpack config file.
baseConfig[0].module.rules.push({
test: /\.jsx?$/,
exclude: [/node_modules\/(?!(@tryghost)\/).*/],
loaders: ['babel-loader'],
}
Please consider this on the next release. Let me know what you think and I will make a PR π
from sdk.
Related Issues (20)
- Add v4 to typings? HOT 2
- Update @tryghost/content-api to support Ghost v4
- Reading time only count latin words
- Admin API uses {} for the body of GET requests causing problems with Google Cloud services HOT 1
- Dependency Dashboard
- Refuse to set unsafe header User-Agent HOT 3
- Can't use v5 with typescript HOT 5
- [ghost admin] Build failure when using @tryghost/admin-api HOT 4
- Cannot convert undefined or null to object HOT 1
- Unable to request multiple pages HOT 2
- [image-transform] Unable to define better image quality than default
- Documentation typos HOT 2
- TypeScript support for the admin api client HOT 6
- Got βInvalid tokenβ in Admin API Token authentication even with the token generated by the Bash (cURL) sample code in Doc. HOT 1
- Consider Migrating Dependency `jsonwebtoken` to `jose` HOT 1
- Unable to uninstall @tryghost/content-api
- Image upload via admin api HOT 1
- Brows Ghost api
- Creating a new member HOT 2
- 'reading_time' parameter not returned when used in 'fields' query of Ghost Content API HOT 1
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 sdk.