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.

Request: Allow only a part of the library to be imported

See original GitHub issue

Dependabot created a pull request to one of our repositories to update from v6 to v7, and the changes in our output were as follows (as reported by bundlesize):

 PASS  ./bundlesize/app.js: 46.65KB < maxSize 75KB gzip (same as master) 

 WARN  ./bundlesize/vendor.js: 289.01KB < maxSize 350KB gzip (5.59KB larger than master, careful!) 

 PASS  ./bundlesize/app.css: 22.66KB < maxSize 50KB gzip (same as master) 

 WARN  ./bundlesize/vendor.css: 3.97KB < maxSize 10KB gzip (864B larger than master, careful!) 

This means updating sweetalert2 resulted in 5.59KB additional JS and 864B additional CSS in our build, while we don’t use the new features. Granted this is not much on its own, but I do see this increasing over time.

Please allow us to only import a part of the codebase, so that we don’t have to include code that we’re not going to use.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
limontecommented, Nov 21, 2017

If it works, it works 😃

The first rule of sys admins 😄 But not for JS developers, we are here to BREAK THINGS! 😈

1reaction
StephanBijzittercommented, Nov 20, 2017

But also, just to be sure, please check that you don’t import the .all.js build of SweetAlert2 (that’s the new entry point) and the CSS file at the same time.

That’s a good point. screen shot 2017-11-20 at 12 03 26 Changing the imports makes the javascript increase go from +5.59KB to +450B, a tenth of the original change!

Now it looks like this:

import 'sweetalert2/src/sweetalert2.scss';
import sweetAlert from 'sweetalert2/dist/sweetalert2.js';

I’d prefer to take both from src, but doing that would lead to an increased javascript size again. Reason for using src would be that we can run it through our own webpack configuration, which also generates sourcemaps for node_modules.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to import only in parts of the code? [Python]
Yes. You move the import statement from the top of the script to the point in your script where you want it. For...
Read more >
Importing Existing Libraries to Your Connected Workspace in ...
Right-click on a library file in the Projects panel and select Import Library from the context menu. Select Tools » Import Library in...
Read more >
Python import: Advanced Techniques and Tips
While it's a good idea to separate scripts and libraries, all Python files can be both executed and imported.
Read more >
5. The import system — Python 3.11.1 documentation
A direct call to __import__() performs only the module search and, if found, ... While certain side-effects may occur, such as the importing...
Read more >
How to import a library in Python – with example - CodeBerry
Pip allows us to install packages from indexes such as the Python Package Index. One of the most commonly installed and used libraries...
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