question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] TreeShaking the modules, exclude Jsonld package.

See original GitHub issue

I am analysing the bundle size of my project. I realised the jsonld is around 17.3 KB parsed while i am using it at all.

Is it possible to import only the NextSeo component?

I tried import NextSeo from "next-seo/meta/defaultSEO.jsx"; and import NextSeo from "next-seo/meta/defaultSEO";, but it doesn’t work.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
garmeehcommented, Jun 7, 2019

Hey @Ktchan825, I’m getting close to publishing V2 of this library. Once published I will investigate tree shaking on it.

2reactions
joeyorlandocommented, Oct 7, 2020

Was trying to accomplish the same thing as @Ktchan825, ended up having to import directly from the ES module file (/lib/next-seo.modern.js). In my case looked something like this:

import {
  DefaultSeo,
  LogoJsonLd,
  LocalBusinessJsonLd,
  SocialProfileJsonLd,
  CorporateContactJsonLd,
} from 'next-seo/lib/next-seo.modern';

I am also using Typescript in my project. After changing my import from from 'next-seo to from 'next-seo/lib/next-seo.modern it started complaining that it couldn’t find the type files for next-seo/lib/next-seo.modern. I was able to fix this by modifying my tsconfig.json as such:

{
  "compilerOptions": {
    "baseUrl": ".", // neccessary if paths is specified
    "paths": {
      "next-seo/lib/next-seo.modern": [
        "node_modules/next-seo/lib"
      ]
    }
  },
  ..<rest of config>
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Tree Shaking - webpack
Tree shaking is a term commonly used in the JavaScript context for dead-code elimination. It relies on the static structure of ES2015 module...
Read more >
Tree shaking and code splitting in webpack - LogRocket Blog
What is tree shaking? Tree shaking, also known as dead code elimination, is the practice of removing unused code in your production build....
Read more >
@parcel/validator-typescript | Yarn - Package Manager
Fix :export in CSS modules; Don't remove unused classes or @keyframes when a CSS module is processed by postcss; Fix bundling issue with...
Read more >
rtvjs - npm
The package's ./dist directory contains 3 types of builds: ... The CJS and ESM builds require defining the process.env.NODE_ENV to either "development" or...
Read more >
Adobe Captivate Users Group | Hello everyone! - Facebook
Hello Daniel Piñerez did you test to import your scorm package on a other LMS? Maybe on cloud scorm.. And did you already...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found