Giter Club home page Giter Club logo

Comments (8)

FBRAA avatar FBRAA commented on June 23, 2024 2

@FBRAA sorry, I could not fully get your point....

You mean we should provide mjs and cjs together? Or We should provide a default export?

Readme should have information on how the import statement should be written in order your plugin to function.

As a fresh user, I firstly tried:

const TimeAnalytics = require('time-analytics-webpack-plugin'); 
const Plugin = TimeAnalytics();

it didnt work

then I tried

import TimeAnalytics from 'time-analytics-webpack-plugin'); 
const Plugin = TimeAnalytics();

didn't work also

then I tried using it as is, because TimeAnalytics() could not be function;

then I went to
const TimeAnalyticsPlugin = require('time-analytics-webpack-plugin');

console.logged it and got [Getter], which confused me,

then I had to go through files of your file, calculating more options on 'HOW TO IMPORT' topic,

finally somehow I reached this variant:

const { TimeAnalyticsPlugin } = require('time-analytics-webpack-plugin');

So, if there are options on how to import your plugin, they should be listed. If it is the only option, it should be written to README as well.
As far as I can see, most of plugins are imported to my project this way, and so was speed-measurement one. Maybe it would be good to make your way of import look same:
image

from time-analytics-webpack-plugin.

FBRAA avatar FBRAA commented on June 23, 2024 1

Hello, I think would be great to add the import statement of plugin, like
const { TimeAnalyticsPlugin } = require('time-analytics-webpack-plugin');
as it different from the origin plugin

from time-analytics-webpack-plugin.

ShuiRuTian avatar ShuiRuTian commented on June 23, 2024

Ah, I think there is a not bad README file in fact: https://github.com/ShuiRuTian/time-analytics-webpack-plugin/tree/main/packages/time-analytics-webpack-plugin

Could this README resolve your problem? If not, what else you think could make the readme better?

But you are right, maybe I need to make this README file more easy to access in the root page....

Why it's not in the root page:

The main purpose is to give a good README page in npm website, which is my prefer way when I want to read the info for a package.

from time-analytics-webpack-plugin.

ShuiRuTian avatar ShuiRuTian commented on June 23, 2024

Will close this issue after one week if there is no response.

Thanks for the feedback!

from time-analytics-webpack-plugin.

ShuiRuTian avatar ShuiRuTian commented on June 23, 2024

@FBRAA sorry, I could not fully get your point....

You mean we should provide mjs and cjs together? Or We should provide a default export?

from time-analytics-webpack-plugin.

jackykwan-eventx avatar jackykwan-eventx commented on June 23, 2024

i think the Readme is not showing enough information
We can take a look at speed-measurement, they show:

  • How to install
  • How to import to webpack config
  • How to apply in existing code base (usage)

https://www.npmjs.com/package/speed-measure-webpack-plugin
image

Tbh, i can not find how to use this package in Readme

from time-analytics-webpack-plugin.

ShuiRuTian avatar ShuiRuTian commented on June 23, 2024

@FBRAA Thanks for the detailed response!

You are right, I missed this part. The README is updated now. Please feel free to give more feedback if you think it's still not good enough.

But it's intentional to use "named export" rather than "default export". Although we only have one object exported.

The main motivation is to use IDE function -- auto complete. If a package uses default export, there is not an "official name" and you need to type a proper text as the name.

Like in

import TerserPlugin from 'terser-webpack-plugin'

you always need to type "TerserPlugin". And any other text is valid, it's just your choice.

But if a package use "named export", then you could trigger auto complete like

import {/* Trigger auto complete here */} from 'my-plugin' // in VSCode, use ctrl+space to trigger

The only valid "official name" could be used. If you want to rename the export object, you need as keyword.

from time-analytics-webpack-plugin.

ShuiRuTian avatar ShuiRuTian commented on June 23, 2024

@jackykwan-eventx The README is updated.

Although I think we did have "How to use" section...

Any more feedback is welcomed if you think it's still not enough.

from time-analytics-webpack-plugin.

Related Issues (8)

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.