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

feat: Support export default in migrations #344

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jrf0110
Copy link

@jrf0110 jrf0110 commented Apr 24, 2020

Summary

This makes it so migrations can export their migration functions using ES module syntax in TS-Node or after running through webpack.

import { MigrationFunction } from 'contentful-migration'

const migrate: MigrationFunction = (migration) => {
  const dog = migration.createContentType('dog');
  const name = dog.createField('name');
  name.type('Symbol').required(true);
}

export default migrate

Motivation and Context

I had been receiving this error:

TypeError: migrationCreator is not a function
    at node_modules/contentful-migration/src/lib/migration-steps/index.ts:335:12

Saw some others as well:

@dsbrianwebster
Copy link

@jrf0110 yes to this! Can we get a review from @Khaledgarbaya or someone at contentful?

@colinwirt
Copy link

Thanks @jrf0110 :)

@Khaledgarbaya @ruderngespra I'd love to see something like this supported to fit-in with fairly strict linting! Sometimes I find a project bans ignoring errors caused by this module syntax making it tough to work out how many levels of ignores are needed :/

It would be great to have this PR reviewed 🤓

@ItsDaveB
Copy link

This is still an issue, would be great to support this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants