Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lack of Javascript examples #6605

Closed
mryellow opened this issue Jun 3, 2024 · 5 comments
Closed

Lack of Javascript examples #6605

mryellow opened this issue Jun 3, 2024 · 5 comments
Labels
documentation Improvements or additions to documentation

Comments

@mryellow
Copy link

mryellow commented Jun 3, 2024

Documentation Issue

Documentation examples are all TypeScript. These require extra dependencies and build tools along with non-standard syntax.

Additional Details

An example should be provided which uses pure ordinary standard Javascript.

No tsc should be required.

@mryellow mryellow added the documentation Improvements or additions to documentation label Jun 3, 2024
@mryellow
Copy link
Author

mryellow commented Jun 4, 2024

src/payload.config.js

const fspath = require('path');

//const payloadCloud = require('@payloadcms/plugin-cloud').payloadCloud;
const mongooseAdapter = require('@payloadcms/db-mongodb').mongooseAdapter;
const webpackBundler = require('@payloadcms/bundler-webpack').webpackBundler;
const slateEditor = require('@payloadcms/richtext-slate').slateEditor;
const buildConfig = require('payload/config').buildConfig;

const Users = require('./collections/Users');
const Posts = require('./collections/Posts');

module.exports = buildConfig({
	admin: {
		user: Users.slug,
		bundler: webpackBundler(),
		components: {},
	},
	editor: slateEditor({}),
	collections: [Users, Posts],
	//typescript: {
	//	outputFile: fspath.resolve('payload-types.ts'),
	//},
	graphQL: {
		disable: true, // NOTE: Running with "NODE_ENV=production" causes issues when not using TypeScript
		disablePlaygroundInProduction: true,
		schemaOutputFile: fspath.resolve('generated-schema.graphql'),
	},
	//plugins: [payloadCloud()],
	plugins: [],
	db: mongooseAdapter({
		url: process.env.DATABASE_URI,
	}),
});

src/server.js

const express = require('express');
const payload = require('payload');

require('dotenv').config();
const app = express()

app.get('/', (_, res) => {
	res.redirect('/admin')
});

const start = () => {
	return Promise.resolve()
		.then(() => payload.init({
			debug: true,
			telemetry: false,
			secret: process.env.PAYLOAD_SECRET,
			express: app,
			onInit: () => {
				payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
			},
		}))
		.then(() => {
			console.log('Starting server!', process.env.PAYLOAD_PORT || 3000);
			app.listen(process.env.PAYLOAD_PORT || 3000);
		});
};

start();

copyfiles -u 1 "src/**/*.js" dist/

cross-env PAYLOAD_CONFIG_PATH=dist/payload.config.js NODE_ENV=foo node dist/server.js

@mryellow
Copy link
Author

mryellow commented Jun 4, 2024

cross-env PAYLOAD_CONFIG_PATH=src/payload.config.js payload build is not required and causes WASM errors on some systems regardless.

@denolfe
Copy link
Member

denolfe commented Jun 4, 2024

Hey @mryellow , we've found that the vast majority of our users are using TypeScript, so the documentation is written with that in mind.

While you can still use Payload with vanilla JS, maintaining documentation and examples of this is something we've decided not to do at this point in time.

@denolfe denolfe closed this as completed Jun 4, 2024
@mryellow
Copy link
Author

mryellow commented Jun 17, 2024

our users are using TypeScript

The only reason for that is that you've failed to document how Javascript users can get the system working.

It's a Survivorship Bias you are seeing as a result of your Selection Bias.

I'm not using TypeScript and made the effort to demonstrate how it can be done.

I didn't require any of the extra build tools in order to get the project working.

No JSX was required. No TypeScript was required.

Copy link

github-actions bot commented Sep 7, 2024

This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants