Skip to main contentdfsdf

Jeremy Gollehon
  • Absolute path imports

    What if you could do

    import MyComponent from "components/MyComponent"

    from anywhere, instead of having to count the “../” and do something like

    import MyComponent from "../../../components/MyComponent"

    This is far from needed, but I feel it can be useful, and as it took me some time to make it work with both VS Code and create-react-app, I thought I might share it.

    There are two aspects for this to be possible. First, you need to tell webpack that you want your path to include your “src” folder. Then, you want VS Code to be aware of this choice.

    Create-react-app has a way of defining environment variables via .env files. Create a file named “.env” file at the root of your application, and define the NODE_PATH variable:


    Then, create a file named “jsconfig.json”, also at the root of your application:

    "compilerOptions": {
    "target": "ES6",
    "module": "commonjs",
    "allowSyntheticDefaultImports": true,
    "baseUrl": "./src/",
    "paths": {
    "*": [
    "exclude": [

    More info on why it works in this documentation.

Jeremy Gollehon
  • Decorators are a syntactic convenience, that allows a Python source file to say what it is going to do with the result of a function or a class statement before rather than after the statement.
    • The benefits of using the decorator syntax are:

      1. The name of the function appears only once in the source file.
      3. The reader knows, before the possibly quite long definition of the function, that the decorator function will be applied to it.

3 more annotations...

Show more items

Highlighter, Sticky notes, Tagging, Groups and Network: integrated suite dramatically boosting research productivity. Learn more »

Join Diigo