ant-design / ant-design-colors

:art: Color Palettes Calculator of Ant Design
https://ant.design/docs/spec/colors
MIT License
652 stars 79 forks source link

SyntaxError: Cannot use import statement outside a module #77

Closed cckz closed 3 years ago

cckz commented 3 years ago

hi, bundle crashes after last update

Documents\projects\sed_flexible_reports\node_modules\@ctrl\tinycolor\dist\module\conversion.js:1
import { bound01, pad2 } from './util';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at compileFunction (<anonymous>)
    at wrapSafe (internal/modules/cjs/loader.js:1071:16)
    at Module._compile (internal/modules/cjs/loader.js:1121:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1177:10)
    at Module.load (internal/modules/cjs/loader.js:1001:32)
    at Function.Module._load (internal/modules/cjs/loader.js:900:14)
    at Module.require (internal/modules/cjs/loader.js:1043:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (Documents\projects\sed_flexible_reports\node_modules\@ant-design\colors\dist\index.js:5:18)
    at Module._compile (internal/modules/cjs/loader.js:1157:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1177:10)
    at Module.load (internal/modules/cjs/loader.js:1001:32)
    at Function.Module._load (internal/modules/cjs/loader.js:900:14)
    at Module.require (internal/modules/cjs/loader.js:1043:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (Documents\projects\sed_flexible_reports\node_modules\@ant-design\icons\lib\utils.js:22:15)
peterwiebe commented 3 years ago

I also ran into this problem. I am able to fix it by going into _nodemodules/@ant-design/colors/dis/index.js and changing

var conversion = require('@ctrl/tinycolor/dist/module/conversion');
var formatInput = require('@ctrl/tinycolor/dist/module/format-input');

to this

var conversion = require('@ctrl/tinycolor/dist/conversion');
var formatInput = require('@ctrl/tinycolor/dist/format-input');
peterwiebe commented 3 years ago

or for a more semi-permanent fix until a new release is published is to add the following to package.json until the breaking change is fixed (if you use yarn):

"resolutions": {
  "@ant-design/colors": "5.0.0"
}
jamsinclair commented 3 years ago

/cc @zombieJ @07akioni

For a quick summary, this breaking change might be caused by tree shaking code being included in v5.1.0.

Looks like @zombieJ has fixed this in https://github.com/ant-design/ant-design-colors/pull/75. Hopefully, a new patch release with that commit will resolve this for everyone?

Appreciate the work you all do on this 😸 , many thanks!

zombieJ commented 3 years ago

https://github.com/ant-design/ant-design-colors/commit/0f15e9570ce34a6499229f2ae9312be8c9696758

jamsinclair commented 3 years ago

@zombieJ thanks for the quick fix 🙌 . Anything blocking publishing v5.1.1 to npm? 🙏

iamricky commented 3 years ago

@cckz are you using Next.js?