Skip to content

dynamic import naming doesn't work #4861

Closed
@MarvinXu

Description

@MarvinXu

Do you want to request a feature or report a bug?
bug

What is the current behavior?
I used comment to define chunkname as follows:

import(/* webpackChunkName: "chunk1" */'@/components/chunk1.js')

But in build report there is no chunk name specified and still generate filename as 1.[hash].js

If the current behavior is a bug, please provide the steps to reproduce.
https://github.com/MarvinXu/webpack-chunkname-test

npm install
npm run build

Activity

stevewillard

stevewillard commented on May 12, 2017

@stevewillard

Try with an '='

import(/* webpackChunkName="chunk1" */'@/components/chunk1.js')
MarvinXu

MarvinXu commented on May 12, 2017

@MarvinXu
Author

Try with an '='

import(/* webpackChunkName="chunk1" */'@/components/chunk1.js')

doesn't work.

maelon

maelon commented on May 15, 2017

@maelon

Same problem.
I had to use webpack 1. The old api require.ensure works perfectly in webpack 1.

MarvinXu

MarvinXu commented on May 15, 2017

@MarvinXu
Author

To be clear, I use the latest webpack(2.5.1) in my project. The require.ensure method works fine with the chunkname, it's just comment definition in import() doesn't work. I don't know where went wrong.

I added require.ensure test in my project:
https://github.com/MarvinXu/webpack-chunkname-test

ematipico

ematipico commented on May 15, 2017

@ematipico
Contributor

I use this feature (2.5.1) and it works fine to me. The only difference is that I don't have the '@' inside the path of my dynamic module; instead I have a relative path.

MarvinXu

MarvinXu commented on May 15, 2017

@MarvinXu
Author

@ematipico '@' is an alias for 'src', I've tested it is not relevant to this.

maelon

maelon commented on May 15, 2017

@maelon

I also set an alias for path, so it fails here?

a573367014

a573367014 commented on May 24, 2017

@a573367014

I have the same problem

quantizor

quantizor commented on May 24, 2017

@quantizor
Contributor

It works for me without the @ - might be something with your setup. (I'm on OS X, for reference.)

silen-z

silen-z commented on May 26, 2017

@silen-z

I've encountered this and it turned out I had to set output.chunkFilename in my webpack config

MarvinXu

MarvinXu commented on Jun 1, 2017

@MarvinXu
Author

It works for me without the @ - might be something with your setup. (I'm on OS X, for reference.)

@probablyup
Did you test on my project? I removed alias '@' just now. Can you test it for me once more?

6220119

6220119 commented on Jun 9, 2017

@6220119

This is not related to Webpack as @MarvinXu is using vue-cli with webpack template to generate the project. This issue should be closed

devinRex

devinRex commented on Aug 16, 2017

@devinRex

Same problem. Does someone find the solution?

28 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @stevewillard@rphl@ericbiewener@mikeaustin@quantizor

        Issue actions

          dynamic import naming doesn't work · Issue #4861 · webpack/webpack