Coder Social home page Coder Social logo

Comments (6)

jimmywarting avatar jimmywarting commented on June 1, 2024

hmm,
Using whitespace with closure-compiler is not a solution since it will not transpile es6 down to old syntax. But i saw a option for pretty print...

Would a source map be a solution also?

from formdata.

jaydenseric avatar jaydenseric commented on June 1, 2024

It is best practice not to ship minified (or bundled) code to npm; that is best performed by the consumer in their project.

I suggest removing the build script and minified file. If the source needs to be transpiled, you can use Babel dev dependencies and setup a prepare package script. That way users can install this package as a git dependency to try out forks/PRs, etc.

from formdata.

jimmywarting avatar jimmywarting commented on June 1, 2024

It is best practice not to ship minified (or bundled) code to npm; that is best performed by the consumer in their project.

I did that before, it ended up with ppl complaining that the polyfill didn't work in there build step - they might just have used a simple gulp script to concatenate all files without babel or something like it

I suggest removing the build script and minified file. If the source needs to be transpiled, you can use Babel dev dependencies and setup a prepare package script. That way users can install this package as a git dependency to try out forks/PRs, etc.

I'm not keen to switch to using another compiler. and ppl are probably already hot linking to github using jsdelivr so i'm not removing the minified file either - and i will keep updating the minified file for future references


if you don't want to use the minifed version you could always include the es6 version right await
require('formdata-polyfill/FormData.js')


Another idea maybe is to change the code to be written with es5 instead - thoughts?

from formdata.

jaydenseric avatar jaydenseric commented on June 1, 2024

I did that before, it ended up with ppl complaining that the polyfill didn't work in there build step - they might just have used a simple gulp script to concatenate all files without babel or something like it

It sounds like you were publishing untranspiled source code. You should publish transpiled code, just don't minify (or bundle) it.

The generally accepted standard for published code used to be ES5. But best practice today is to establish a browserslist query, and let @babel/preset-env transpile the source code to your chosen level of browser support. Personally I use > 0.5%, not dead, node 6:

https://github.com/jaydenseric/extract-files/blob/v5.0.1/package.json#L35

Something else good to do is to publish native ESM in sibling .mjs files. You do all the the other transpilations except you retain the ESM syntax:

https://github.com/jaydenseric/extract-files/blob/v5.0.1/package.json#L60
https://github.com/jaydenseric/extract-files/blob/v5.0.1/babel.config.js#L7

from formdata.

jimmywarting avatar jimmywarting commented on June 1, 2024

It sounds like you were publishing untranspiled source code. You should publish transpiled code, just don't minify (or bundle) it.

Correct - Personally I rather have a sourcemap that points to the actual part of the code rather then to some place in the transpiled place

from formdata.

stale avatar stale commented on June 1, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

from formdata.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.