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.

no effect - how to check if even loaded?

See original GitHub issue

I probably have something wrong with my configuration. ts-jest makes use of the same underlying tsconfig-paths library right? it doesn’t have any problems running tests. The error I get is

ERROR in ./src/app/root/application.tsx
Module not found: Error: Can't resolve '_modules/ui/tgr/page' in '/home/falieson/Code/Publications/tgrstack/skeletons/skeleton-tgr-app-express/src/app/root'
 @ ./src/app/root/application.tsx 7:13-44
 @ ./src/app/index.tsx

My project is structured like this

/webpack/webpack.js
/tsconfig.js
/src/

TSconfig.json is like this

    "baseUrl": ".",                           /* Base directory to resolve non-absolute module names. */
    "paths": {                                /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
      "*":              ["node_modules/*", "src/*",],
      // list of submodules matching tslint
      "!server/*":      ["src/server/*"],
      "!app/*":         ["src/app/*"],

      // implicitely app modules
      "_modules/*":     ["src/app/modules/*"],
    },

Webpack config is like this


const rootPath = path.resolve(__dirname, '..')
const srcPath = path.resolve(rootPath, 'src')
const paths = {
    _: rootPath,
    src: { _: srcPath },
}

const typescript = (() => {
  const configFile = path.resolve(paths._, 'tsconfig.json') 
  const tsOptions = {
    context: paths._,
    configFile,
    transpileOnly: true,
  }
  const loader = {
    test: /\.tsx?$/,
    include: paths.src._,
    use: [
      {
        loader: 'babel-loader',
        options: {
          babelrc: true,
        }
      },
      {
        loader: 'ts-loader',
        options: tsOptions
      }
    ]
  }

  const tsPaths = new TsconfigPathsPlugin({
    logLevel: 'info',
    configFile,
  })

  return {
    loader,
    paths: tsPaths,
  }
})()

module.exports = {
  node: {
    __dirname: false,
    __filename: false,
  },
  resolve: {
    extensions: ['.csv', '.ts', '.tsx', '.js', '.json', '.jsx'],
    modules: ['src', 'node_modules'],
  },
  module: {
    rules: [
      typescript.loader,
      // graphql,
      files,
    ],
  },
  plugins: [
    new Dotenv(dotEnvOpts),
    typescript.paths
  ],
}

Thanks for your consideration

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:5

github_iconTop GitHub Comments

1reaction
akopchinskiycommented, Sep 18, 2019

Same issue here.

Project structure:

/
--/source
--/tests
tsconfig.json
tsconfig.lib.json
webpack.config.ts
// webpack.config.ts


const config: webpack.Configuration = {
    target: 'web',
    
    entry: {
        '@lib': `${source}/module.ts`
    },
    output: {
        path: path.resolve(__dirname, build),
        filename: 'module.js'
    },

    // Dev tools
    devtool: 'source-map',

    module: {
        rules: [
            {
                test: /\.ts$/,
                loader: 'ts-loader'
            }
        ]
    },

    resolve: {
        extensions: ['.ts'],
        plugins: [
            new TsConfigPathsPlugin({ 
                configFile: './tsconfig.lib.json'
            })
        ]
    },
    plugins: [
        new WpClean([build]),
        new CopyWebpackPlugin([{
            from: `./package.json`
        }])
    ]
};

export default config;

tsconfig.lib.json

{
    "compileOnSave": true,
    "compilerOptions": {
        "module": "umd",
        "target": "es6",
        "declaration": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": true,
        "esModuleInterop": true,
        "lib": [
            "esnext",
            "dom"
        ],
        "types": [
            "node"
        ],
        "rootDir": ".",
        "baseUrl": "./source",
        "outDir": "lib",
        "typeRoots": [
            "./node_modules/@types/"
        ]
    },
    "include": [
        "./**/*"
    ],
    "exclude": [
        "./**/*.test.*",
        "./node_modules/"
    ]
}
1reaction
c-vettercommented, Apr 19, 2019

From the README:

Notice that the plugin is placed in the resolve.plugins section of the configuration. tsconfig-paths-webpack-plugin is a resolve plugin and should only be placed in this part of the configuration. Don’t confuse this with the plugins array at the root of the webpack configuration object.

So, just move typescript.paths into resolve.plugins instead of plugins and you should be good.

Might be a good idea to move that note further toward the top 🤔

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Hooks: useEffect() is called twice even if an empty array ...
Put the console.log inside the useEffect. Probably you have other side effects that cause the component to rerender but the useEffect itself ...
Read more >
Browser-level image lazy loading for the web - web.dev
This post covers the loading attribute and how it can be used to control the loading of images.
Read more >
.load() | jQuery API Documentation
This method is a shortcut for .on( "load", handler ) . The load event is sent to an element when it and all...
Read more >
Lazy loading - Web performance | MDN
You can determine if a given image has finished loading by examining the value of its Boolean complete property. Polyfill Include this polyfill ......
Read more >
Bypass, remove, or rescan Audio Units plug-ins in Logic Pro ...
If you can't find a recently installed plug-in, restart your Mac, confirm the ... If the plug-in is still not available, check with...
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