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

Modularization and more organized project structure #19

Merged
merged 7 commits into from
Apr 8, 2022

Conversation

chessl
Copy link
Contributor

@chessl chessl commented Apr 3, 2022

First PR of a series of changes proposed in #15, sorry for such delay. Modularization for portability and accessibility. Reorganizes project structure, and switches to rollup as the builder to provide both cjs and umd outputs and better workflow for future development.

Copy link
Owner

@samthor samthor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general this is fine.

But I wonder if we can remove the dist code from the repo and just publish it to NPM?

test.js Outdated Show resolved Hide resolved
src/index.js Show resolved Hide resolved
rollup.umd.config.js Outdated Show resolved Hide resolved
@chessl
Copy link
Contributor Author

chessl commented Apr 5, 2022

You are absolutely right, they are totally unnecessary, I've just removed them.

package.json Outdated
"test": "npm run build:umd-polyfill && headless-test --cors test.js",
"closure": "google-closure-compiler --js=src/*.js --checks_only --module_resolution=node --compilation_level=ADVANCED",
"build": "run-p build:**",
"build:cjs": "rollup -i src/index.js -o lib/index.js -f cjs",
Copy link

@kuitos kuitos Apr 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could write a set of configuration in a single rollup.config.js file, rather than make a series npm scripts to do the same things:

export default {
  {
    input: 'src/index.js',
    output: [
      {
        file: 'lib/index.js',
        format: 'cjs'
      },
      {
        file: 'es/index.js',
        format: 'es'
      }
    ]
  }
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so your build script can simplified to one line command "build": "rollup"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool cool, didn't know that. Just updated the rollup config.

output: [
{
file: 'dist/polyfill.js',
format: 'umd'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not convinced anyone actually wants umd, but there's probably no harm in it.

I guess I am a bit confused why umd doesn't get the document setup stuff that's in index.

@samthor samthor merged commit f094455 into samthor:master Apr 8, 2022
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.

3 participants