Skip to content

[BUG] Code splitting not working. #17

@mnlbox

Description

@mnlbox

I checked the code splitting branch and it seems it's not working. After doing changes and try using the component-library in a test app (created by CRA) I got this error: (I build and re-install the package after add code splitting and run yarn cache clean)

./src/App.tsx
Cannot find module: 'react-component-library/build/TestComponent/TestComponent'. Make sure this package is installed.

You can install this package by running: yarn add react-component-library/build/TestComponent/TestComponent.


error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I tried to access TestComponent exactly the same as you told in your article, like this:

import TestComponent from 'react-component-library/build/TestComponent/TestComponent';

Also, this is the folder structure after code-splitting contains folders like node_modules and src and it's not clean enough:

.
├── index.d.ts
├── node_modules
│   └── style-inject
│       └── dist
│           ├── style-inject.es.js
│           └── style-inject.es.js.map
├── src
│   ├── index.js
│   ├── index.js.map
│   ├── TestComponent
│   │   ├── index.js
│   │   ├── index.js.map
│   │   ├── TestComponent.js
│   │   ├── TestComponent.js.map
│   │   ├── TestComponent.scss.js
│   │   └── TestComponent.scss.js.map
│   └── TestComponentNew
│       ├── index.js
│       ├── index.js.map
│       ├── TestComponentNew.js
│       ├── TestComponentNew.js.map
│       ├── TestComponentNew.scss.js
│       └── TestComponentNew.scss.js.map
├── TestComponent
│   ├── index.d.ts
│   ├── TestComponent.d.ts
│   └── TestComponent.types.d.ts
├── TestComponentNew
│   ├── index.d.ts
│   ├── TestComponentNew.d.ts
│   └── TestComponentNew.types.d.ts
├── typography.scss
└── variables.scss

It's better to able import component in code splitting like this:

import TestComponent from 'react-component-library/TestComponent';

Rather than this:

import TestComponent from 'react-component-library/build/TestComponent/TestComponent';

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions