npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@voplus/morpho-workspace

v6.0.166

Published

morpho workspace module

Downloads

1,317

Readme

Typescript support

Install dependencies

npm i typescript ts-loader -D

webpack configuration in webpack.config.js

// ts loader for typescript
{
    test: /\.tsx?$/,
    loader: 'ts-loader',
    exclude: /node_modules/,
},
resolve: {
    extensions: [
        //required for ts imports
        ".tsx", ".ts", 
        //required for js imports (mostly in webpack dev self dependency)
        '.js']
}

Less support

Install dependencies

npm i less less-loader css-loader style-loader -D

Create tsexternals.d.ts with following content

declare module '*.less'

tsconfig configurations

"includes" : ["./tsexternals.d.ts"],

webpack configurations.

// less support for project
// chain less -> css loader (module support) -> style loader (inject styles tag into DOM)
{
    test: /\.less$/,
    include: [path.join(__dirname, "/src")],
    use: [
        {loader: "style-loader"},
        {
        loader: "css-loader",
        options: {
            sourceMap: true,
            modules: true,
            localIdentName: "[local]___[hash:base64:5]"
        }
        },
        {loader: "less-loader"}
    ]
},

Antd support

Install dependencies

npm i @voplus/antd ts-import-plugin -D

webpack configurations

// Add following to beginning of webpack.config.js
const tsImportPlugin = require('ts-import-plugin');

// Add following options to ts-loader rules
options: 
{
    getCustomTransformers: () => ({
    before: [ tsImportPlugin({
        libraryDirectory: 'es',
        libraryName: '@voplus/antd',
        style: true}) 
    ]})
}

// As antd does not support css module (https://segmentfault.com/q/1010000011170368)
// Add following additional less loader 
// less support for antd
// javascriptEnabled are required for antd
{
    test: /\.less$/,
    include: [path.join(__dirname, "/node_modules/@voplus/antd")],
    use: [
        {loader: "style-loader"},
        {loader: "css-loader"},
        {loader: "less-loader", options:  { javascriptEnabled: true}}
    ]
}   

Override antd style reference https://stackoverflow.com/questions/44817981/how-to-override-antd-style-with-dva

Theme

Override less variables

modify '/src/style/theme.js'

Override antd styles in components with modular less

modular css/less will generate a unique class name and make it difficult to override antd class styles. We can use :global to overcome this. Code below demonstrated how to do this.

// Less
.componentClass {
    :global {
        //override ant styles under componentClass
        .ant-btn-primary {
            background-color: @success-color;
        }    
    }
}
// TS
<component className={styles.componentClass}>
    <Button type="primary">Button display with success color instead of primary color.</Button>
</component>

Test Setup

https://hackernoon.com/testing-react-components-with-jest-and-enzyme-41d592c174f

"skipBabel" must set to true if allowSyntheticDefaultImports is true in tsconfig.json. Otherwise debugging with VSCode will have source map issues. 5 Dec 2018 : The above seems no longer needed after updated ts-jest.

Library Build

Modify package.json

"main": "lib/index.js",
"build" : "webpack --config webpack.prod.js && tsc --outDir lib"

Modify tsconfig.json

  1. Remove "allowJs"
  2. Add "declaration" : true

Knowledges

test

[28 Jul 2018]

  • jest skipBabel need set to true otherwise will have strange sourcemap issues.
  • tsconfig need following configuration otherwise awync await may not work "target": "es6", "allowSyntheticDefaultImports":false, "esModuleInterop":false

MacOS build时 cpx命令需要给文件目录加上引号

"copy-less": "cpx 'src/**/*.less' lib && cpx 'src/**/*.less' es && cpx 'src/**/*.css' es",