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.

Project architecture

src/components/index.ts:

export * from './button'; 
export * from './input'; 

src/components/button/index.ts:

export {Button, IProps as IButtonProps} from './Button.tsx';

and the Button is a mere React component.

Playroom

playroom.config.js

module.exports = {
	components: './src/components',
	outputPath: './dist/playroom',
	webpackConfig: () => ({
		module: {
			rules: [
				{
					test: /\.tsx?$/,
					use: [{ loader: 'ts-loader' }]
				}
			]
		}
	})
};

Error

When running playroom start, it produces this error:

$ lerna run --parallel start --scope @myProject/myPackage
lerna notice cli v3.6.0
lerna info filter [ '@myProject/myPackage' ]
lerna info Executing command in 1 package: "yarn run start"
@myProject/myPackage: $ playroom start
@myProject/myPackage: (node:55112) UnhandledPromiseRejectionWarning: /Users/marais/Sites/myProject/packages/myPackage/src/components/index.ts:1
@myProject/myPackage: (function (exports, require, module, __filename, __dirname) { export * from './button';
@myProject/myPackage:                                                               ^^^^^^
@myProject/myPackage: SyntaxError: Unexpected token export
@myProject/myPackage:     at new Script (vm.js:83:7)
@myProject/myPackage:     at createScript (vm.js:267:10)
@myProject/myPackage:     at Object.runInThisContext (vm.js:319:10)
@myProject/myPackage:     at Module._compile (internal/modules/cjs/loader.js:685:28)
@myProject/myPackage:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
@myProject/myPackage:     at Module.load (internal/modules/cjs/loader.js:620:32)
@myProject/myPackage:     at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
@myProject/myPackage:     at Function.Module._load (internal/modules/cjs/loader.js:552:3)
@myProject/myPackage:     at Module.require (internal/modules/cjs/loader.js:658:17)
@myProject/myPackage:     at require (internal/modules/cjs/helpers.js:22:18)
@myProject/myPackage: (node:55112) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
@myProject/myPackage: (node:55112) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
lerna success run Ran npm script 'start' in 1 package in 1.1s:
lerna success - @myProject/myPackage
✨  Done in 1.63s.

Question

Is there a way to make the this work?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
flybayercommented, Dec 14, 2019

This is working for me. I copied it from the internal webpack config and fixed the paths.

    module: {
      rules: [
      {
          test: /\.(ts|tsx)$/,
          include: __dirname,
          exclude: /node_modules/,
          use: {
            loader: require.resolve('babel-loader'),
            options: {
              presets: [
                require.resolve('@babel/preset-env'),
                require.resolve('@babel/preset-react'),
                require.resolve('@babel/preset-typescript')
              ],
              plugins: [
                require.resolve('@babel/plugin-proposal-class-properties')
              ]
            }
          }
        },
        {
          test: /\.js$/,
          include: __dirname,
          exclude: /node_modules/,
          use: {
            loader: require.resolve('babel-loader'),
            options: {
              presets: [
                require.resolve('@babel/preset-env'),
                require.resolve('@babel/preset-react')
              ],
              plugins: [
                require.resolve('@babel/plugin-proposal-class-properties')
              ]
            }
          }
        }
      ],
    },

4reactions
debajyoti-thetaonelabcommented, Nov 12, 2019

After using @DavidHooper & @vensa-albertgao’s config on my CRA with --typescript project I am getting the following issue:

This dependency was not found:

* __PLAYROOM_ALIAS__COMPONENTS__ in ./node_modules/playroom/src/Playroom/components.js

To install it, you can run: npm install --save __PLAYROOM_ALIAS__COMPONENTS__

image

What can it be?

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript: JavaScript With Syntax For Types.
TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale. Try TypeScript Now. Online or...
Read more >
TypeScript - Wikipedia
TypeScript is a free and open source programming language developed and maintained by Microsoft. It is a strict syntactical superset of JavaScript and...
Read more >
TypeScript is a superset of JavaScript that compiles ... - GitHub
TypeScript is a language for application-scale JavaScript. TypeScript adds optional types to JavaScript that support tools for large-scale JavaScript ...
Read more >
TypeScript Introduction - W3Schools
TypeScript is a syntactic superset of JavaScript which adds static typing. This basically means that TypeScript adds syntax on top of JavaScript, ...
Read more >
TypeScript - The Basics - YouTube
TypeScript has forever altered the lives of JavaScript developers. Learn why TS is so awesome and the basic concepts required to be ...
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