Skip to content

postcss-loader causes change in how webpack recognizes modules #646

Closed
@wibed

Description

@wibed

installation of postcss-loader, causes the following error.
i can install postcss standalone just fine and it doesn't mess with the compilation.

error:

CMD: `rimraf dist && cross-env NODE_ENV=development webpack serve --mode=development`
[start:webpack] SyntaxError: Cannot use import statement outside a module
[start:webpack]     at internalCompileFunction (node:internal/vm:73:18)
[start:webpack]     at wrapSafe (node:internal/modules/cjs/loader:1176:20)
[start:webpack]     at Module._compile (node:internal/modules/cjs/loader:1218:27)
[start:webpack]     at Module.m._compile (/work/to/project/node_modules/ts-node/src/index.ts:1618:23)
[start:webpack]     at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
[start:webpack]     at Object.require.extensions.<computed> [as .ts] (/workspace/frickel/zoe4/node_modules/ts-node/src/index.ts:1621:12)
[start:webpack]     at Module.load (node:internal/modules/cjs/loader:1117:32)
[start:webpack]     at Function.Module._load (node:internal/modules/cjs/loader:958:12)
[start:webpack]     at Module.require (node:internal/modules/cjs/loader:1141:19)
[start:webpack]     at require (node:internal/modules/cjs/helpers:110:18)

the webpack config in question:

// client.config.ts
import type { Configuration as WebpackConfiguration } from 'webpack';
import { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server'

interface Configuration extends WebpackConfiguration {
  devServer?: WebpackDevServerConfiguration }

import {
  tsLoader,
  svgLoader,
  cssLoader,
  imageLoader,

  miniCSSPlugin,
  copyPlugin,
  htmlPlugin,
  htmlLoader,
  forkCheckerPlugin
} from './_lib';


import configuration from '../../../.config';


const clientConfiguration: Configuration = {
  name: "client",
  target: "web",
  entry: configuration.dir.src,
  devtool: configuration.is_dev ? "source-map" : false,
  devServer: {
    historyApiFallback: true,
    static: configuration.dir.dist,
    open: true,
    compress: true,
    host: configuration.client.host,
    port: configuration.client.port,
    devMiddleware: { writeToDisk: true }
  },
  output: {
    publicPath: '/',
    path: configuration.dir.dist,
    filename: '[name].bundle.js',
    assetModuleFilename: 'assets/[name][ext]'
  },
  resolve: {
    extensions: ['.js', '.jsx', '.ts', '.tsx'],
    alias: {
      react: configuration.alias_react,
      App: configuration.alias_app,
      assets: configuration.alias_assets,
      components: configuration.alias_components,
      features: configuration.alias_features,
      hooks: configuration.alias_hooks
    }
  },
  module: {
    rules: [
      tsLoader.client,
      svgLoader.client,
      cssLoader.client,
      imageLoader.client,
      htmlLoader.client
    ]
  },
  plugins: [
    miniCSSPlugin,
    copyPlugin,
    htmlPlugin,
    forkCheckerPlugin
  ],
  performance: {
    maxEntrypointSize: 512000,
    maxAssetSize: 512000
  },
  watchOptions: {
    aggregateTimeout: 500,
    poll: 1000,
  },
}

export default clientConfiguration

PS.:
deinstalling postcss-loader alone does not resolve the error.
i have to remove any related package aswell.

 npm r -D   tailwindcss   @tailwindcss/typography   autoprefixer   postcss   postcss-loader

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions