1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Use _ as the divider for dynamic import name splitter. (#2793)

Using - gives us some weird webpack errors.
This commit is contained in:
Arunoda Susiripala 2017-08-17 02:25:27 +05:30 committed by GitHub
parent eafa2c676d
commit a730b04df7

View file

@ -2,7 +2,7 @@
// We've added support for SSR with this version // We've added support for SSR with this version
import template from 'babel-template' import template from 'babel-template'
import syntax from 'babel-plugin-syntax-dynamic-import' import syntax from 'babel-plugin-syntax-dynamic-import'
import { dirname, resolve } from 'path' import { dirname, resolve, sep } from 'path'
import Crypto from 'crypto' import Crypto from 'crypto'
const TYPE_IMPORT = 'Import' const TYPE_IMPORT = 'Import'
@ -62,8 +62,8 @@ export default () => ({
const modulePath = getModulePath(sourceFilename, moduleName) const modulePath = getModulePath(sourceFilename, moduleName)
const modulePathHash = Crypto.createHash('md5').update(modulePath).digest('hex') const modulePathHash = Crypto.createHash('md5').update(modulePath).digest('hex')
const relativeModulePath = modulePath.replace(process.cwd(), '') const relativeModulePath = modulePath.replace(`${process.cwd()}${sep}`, '')
const name = `${relativeModulePath.replace(/[^\w]/g, '-')}-${modulePathHash}` const name = `${relativeModulePath.replace(/[^\w]/g, '_')}_${modulePathHash}`
const newImport = buildImport({ const newImport = buildImport({
name name