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

merge upstream & fix dev script #2

Merged
merged 20 commits into from
Jun 2, 2020
Merged

merge upstream & fix dev script #2

merged 20 commits into from
Jun 2, 2020

Conversation

rixo
Copy link
Contributor

@rixo rixo commented Jun 1, 2020

Hmm. I don't know if this is on purpose or not, but you didn't merge the last PR, just close. So you still have all the commits from my branch in this new PR...

The important commit to fix the dev script issue is this one.

  "svelte": "src/index.js",
  "browser": "src/index.js",
  "module": "dist/index.mjs",
  "main": "dist/index.js",

The "svelte" field is used by Svelte bundler plugins (e.g. rollup-plugin-svelte) to pick the source of Svelte components.

"browser" is usually the field that is picked by bundlers when bundling for browser (as opposed to node, for example). In our case, it seems redundant since all our dists are prod oriented.

"module" is the ESM (import) build that will be used by forward looking codebases.

"main" is the default main field; historically a Node entry point. In this project (and the official template it is copied from), it is a UMD build. I don't know anything about it, but I guess it is a Node & browser compatible module format. In our case, there's not a lot we can do in Node since we are publishing DOM (i.e. for browser) components...

Appart from the "main" field, that is used by Node resolution system, none of this is part of a hard spec. Those are just habits and ad hoc conventions...

Anyway, of note here is that our rollup.config.js is extracting informations from the package.json. The name of the project, but also the module and main fields, as destinations of the build output:

    output: [
      { file: pkg.module, format: 'es' },
      { file: pkg.main, format: 'umd', name },
    ],

If you change one of those fields to src/index.js, then your source file gets overwritten by the build file. On subsequent builds, we're building an already bundled index.js, and we get this funny Rollup error. I would laugh if I hadn't played the exact same joke on myself (building on the src) already and lost 2h getting mad at debugging it >_<

@happybeing
Copy link
Owner

I merged manually but haven't pushed to origin, so only have the changes locally until I push.

Thanks for sorting, I'll pick this up tomorrow.

@happybeing happybeing merged commit c5b6def into happybeing:master Jun 2, 2020
@happybeing
Copy link
Owner

Sorted. Thanks very much. I'm closing this again, and have merged this PR into master manually, and pushed so we should be in sync.

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

2 participants