gajus / gajus/babel-plugin-react-css-modules
`exclude` won't work with `require.context`
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- JavaScript
- Star
- 2k
- Fork
- 159
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
Hi,
I'll try to open a PR if I get no where, but I'd like to exclude a file from being transformed, but that file is required via require.context. when debugging, here is the output of stats when it tries to go over the file (config.js) that uses require.context:
PluginPass {
_c: Map {},
dynamicData: {},
plugin:
Plugin {
_c: Map {},
dynamicData: {},
initialized: true,
raw: {},
key: 'react-css-modules',
manipulateOptions: [Function: manipulateOptions],
post: undefined,
pre: undefined,
visitor:
{ _exploded: {},
_verified: {},
ImportDeclaration: [Object],
JSXElement: [Object],
Program: [Object] } },
key: 'react-css-modules',
file:
File {
_c: Map {},
dynamicData: {},
pipeline: Pipeline {},
log:
Logger {
filename: '/Users/mshertzberg/Gizmodo/kinja-components/.storybook/config.js',
file: [Circular] },
opts:
{ filename: '/Users/mshertzberg/Gizmodo/kinja-components/.storybook/config.js',
filenameRelative: '/Users/mshertzberg/Gizmodo/kinja-components/.storybook/config.js',
inputSourceMap: undefined,
env: [Object],
mode: undefined,
retainLines: false,
highlightCode: true,
suppressDeprecationMessages: false,
presets: [],
plugins: [Object],
ignore: [],
only: undefined,
code: true,
metadata: true,
ast: true,
extends: undefined,
comments: true,
shouldPrintComment: undefined,
wrapPluginVisitorMethod: undefined,
compact: 'auto',
minified: false,
sourceMap: false,
sourceMaps: false,
sourceMapTarget: 'config.js',
sourceFileName: '.storybook/config.js',
sourceRoot: '/Users/mshertzberg/Gizmodo/kinja-components',
babelrc: false,
sourceType: 'module',
auxiliaryCommentBefore: undefined,
auxiliaryCommentAfter: undefined,
resolveModuleSource: undefined,
getModuleId: undefined,
moduleRoot: '/Users/mshertzberg/Gizmodo/kinja-components',
moduleIds: false,
moduleId: undefined,
passPerPreset: false,
parserOpts: false,
generatorOpts: false,
basename: 'config' },
parserOpts:
{ sourceType: 'module',
sourceFileName: '/Users/mshertzberg/Gizmodo/kinja-components/.storybook/config.js',
plugins: [Object] },
pluginVisitors: [ [Object] ],
pluginPasses: [ [Object] ],
metadata: { usedHelpers: [], marked: [], modules: [Object] },
dynamicImportTypes: {},
dynamicImportIds: {},
dynamicImports: [],
declarations: {},
usedHelpers: {},
path:
NodePath {
parent: [Object],
hub: [Object],
contexts: [Object],
data: {},
shouldSkip: false,
shouldStop: false,
removed: false,
state: undefined,
opts: [Object],
skipKeys: {},
parentPath: null,
context: [Object],
container: [Object],
listKey: undefined,
inList: false,
parentKey: 'program',
key: 'program',
node: [Object],
scope: [Object],
type: 'Program',
typeAnnotation: null },
ast:
Node {
type: 'File',
start: 0,
end: 722,
loc: [Object],
program: [Object],
comments: [],
tokens: [Object] },
code: 'import \'preact/devtools\';\nimport {\n\tconfigure,\n\taddDecorator,\n\twithCentered,\n\twithKnobs,\n\tsetOptions\n} from \'../config/storybook\';\nimport { StyletronHOC } from \'../config/styletron\';\n\nfunction loadStories() {\n\tconst req = require.context(\'../components\', true, /story.js$/);\n\treq.keys().forEach(filename => req(filename));\n}\n\naddDecorator(getStory => <StyletronHOC>{getStory()}</StyletronHOC>);\naddDecorator(withCentered);\naddDecorator(withKnobs);\n\nsetOptions({\n\tname: \'kinja-components\',\n\turl: \'https://github.com/gawkermedia/kinja-components\',\n\tgoFullScreen: false,\n\tshowLeftPanel: true,\n\tshowDownPanel: true,\n\tshowSearchBox: false,\n\tdownPanelInRight: true,\n\tsortStoriesByKind: true\n});\n\nconfigure(loadStories, module);\n',
shebang: '',
hub: Hub { file: [Circular], options: undefined },
scope:
Scope {
uid: 16,
parent: null,
hub: [Object],
parentBlock: [Object],
block: [Object],
path: [Object],
labels: [Object],
references: [Object],
bindings: [Object],
globals: [Object],
uids: {},
data: {},
crawling: false } },
opts:
{ generateScopedName: '[hash:base64:10]',
webpackHotModuleReloading: true,
exclude: 'story',
filetypes: { '.scss': 'postcss-scss' } } }
I would imagine this requires a PR to implement?
Thanks.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Tái hiện vấn đề từ .storybook/config.js, tập trung vào lệnh gọi require.context và tùy chọn exclude được hiển thị. Kiểm tra cách việc loại trừ được áp dụng khi các tệp được tải qua context đó. Hoàn tất khi tệp dự kiến bị loại trừ không được biến đổi, trong khi các tệp khác được tải qua context vẫn tiếp tục hoạt động.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript
- Lĩnh vực
- tooling
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 32/100