gajus / gajus/babel-plugin-react-css-modules
`exclude` won't work with `require.context`
- Lenguaje dominante
- JavaScript
- Estrellas
- 2k
- Forks
- 159
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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 => {getStory()});\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.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Reproduce el problema desde .storybook/config.js, centrándote en la llamada a require.context y en la opción exclude mostrada. Inspecciona cómo se aplica la exclusión cuando los archivos se cargan mediante ese contexto. Se considera terminado cuando el archivo que se pretende excluir no se transforma, mientras que los demás archivos cargados mediante el contexto siguen funcionando.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript
- Área
- tooling
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 32/100