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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormData import not working #1112

Closed
wants to merge 33 commits into from
Closed

FormData import not working #1112

wants to merge 33 commits into from

Conversation

jdalrymple
Copy link
Owner

@jdalrymple jdalrymple commented Aug 24, 2020

Summary

The export of the FormData library seems to cause a problem when in combination of the latest rollup release.

  • import FromData from 'form-data' doesnt work "form_data_1.default is not a constructor"
  • import * as FormData from 'form-data' doesnt work since the bundled output isnt of type constructor (its of type object)
  • import FormData = require('form-data') doesnt work since require isnt supported in es modules
  • const FormData = require('form-data') doesnt work because require isnt supported in the browser.

I havent received any applicable feedback form-data/form-data/issues/470, form-data/form-data/issues/441

Possible solutions

  • this may help if it ever gets merged. Not sure how to go about fixing this :/
  • downgrade rollup to before 2.26, though this will only work short term
  • 馃あ fork form-data

@jdalrymple jdalrymple marked this pull request as draft August 24, 2020 12:24
@jdalrymple jdalrymple changed the title FormData creating more annoyances again FormData import not working Aug 24, 2020
@jdalrymple
Copy link
Owner Author

This is blocking everything in the pipeline. For now, ill downgrade rollup to before 2.26 to see if that helps, and come back to this proper afterward

@jdalrymple
Copy link
Owner Author

jdalrymple commented Sep 8, 2020

Still tackling this. Latest work includes:

  1. Fixing related typing that was causing an issue
  2. Debugging FormData imports. This lead to me switching to formdata-node but im still having issues. Currently the blocker is:
Error: 'default' is not exported by node_modules/formdata-node/lib/FormData.js, imported by src/index.ts

using a test repo:

src/index.ts

import FormDataI from 'formdata-node'

const c = new FormDataI()

export { c }

with a rollup config of :

import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import nodePolyfills from 'rollup-plugin-node-polyfills';
import globals from 'rollup-plugin-node-globals';
import pkg from './package.json';
import ts from 'rollup-plugin-typescript2';
import typescript from 'typescript';


export default [
  {
    input: 'src/index.ts',
    output: {
      file: 'dist/out.js',
      name: 'gitbeaker',
      format: 'umd',
      // exports: 'named',
    },
    plugins: [globals(), nodePolyfills(), json(), ts({ typescript, useTsconfigDeclarationDir: true }), resolve(), commonjs()],
  },
];

Still trying to figure out how to fix this sigh

@jdalrymple
Copy link
Owner Author

Tracking error here

@jdalrymple
Copy link
Owner Author

Got everything to compile properly again! Just fixing up the unit tests now.

@jdalrymple
Copy link
Owner Author

Still running into an issue with the integration tests. Gonna go back to the drawing board and debug step by step

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.

None yet

1 participant