-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Output dir support #583
Output dir support #583
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
@@ -441,6 +442,8 @@ export default function(babel: Babel) { | |||
// path.hub.file.opts.filename !== 'unknown' || | |||
state.opts.extractStatic | |||
|
|||
state.outputDir = state.opts.outputDir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to do this, just use state.opts.outputDir
. The only reason it's done for extractStatic
is because it used to be determined by other things like as you can see, whether there was a filename passed to babel.
// add emotion.css as an extension | ||
cssFilenameArr.push('emotion.css') | ||
|
||
// use absolute path so resolving can't go wrong |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't rely on absolute paths. There are so many times when it would cause problems, for example, distributing an npm package, the imports wouldn't work since they would point to paths that wouldn't exist on a consumers computer. Please use path.relative
to get relative paths instead.
so require statements are made relative but disk operations are resolved paths. I've fixed the tests and tested it on a local project. |
@tkh44 what's wrong with babel 7? or nothing we should deal with yet? |
I hit this problem but got called away and didn’t investigate yet.
…On Tue, Mar 6, 2018 at 1:44 PM Ward Peeters ***@***.***> wrote:
@tkh44 </~https://github.com/tkh44> what's wrong with babel 7? or nothing
we should deal with yet?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#583 (comment)>,
or mute the thread
</~https://github.com/notifications/unsubscribe-auth/AAoc3qeQZR3pRrFTQ9vHzY5P6onO0EQZks5tbvUigaJpZM4SZ8e2>
.
|
const cssFilename = filenameArr.join('.') | ||
const exists = fs.existsSync(cssFilename) | ||
addSideEffect(path, './' + nodePath.basename(cssFilename)) | ||
let cssFilename = path.hub.file.opts.sourceFileName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if you replace path.hub.file.opts.sourceFileName
with path.hub.file.opts.generatorOpts ? path.hub.file.opts.generatorOpts.sourceFileName : path.hub.file.opts.sourceFileName
the babel 7 error will be fixed.
Codecov Report
|
Thanks @wardpeet! |
Having the problem with new Babel 7 beta release:
Seems like it tries to require CSS file from the place near component, but didn’t found it because now Emotion put all files to the same output dir. Maybe there is a way to enable old behavior to put every file near component's JS file? |
Also I afraid to file name conflict. What if we have |
Maybe we can have old behavior on |
The behaviour should be the following |
@wardpeet @tkh44 @mitchellhamilton I got a strange result with extract static. I know it's a deprecated feature but at the moment i can't switch to linaria o css-literal-loader. Please(on my knees) is it possibile to only have this fix in the babel plugin?Or a way to workaroud for now? Problem: babel src --out-dir esm --ignore 'src/**/*.spec.js,src/**/*.test.js' --copy-files I got this result:
import "../../Projects/src/Accordion/AccordionItem.emotion.css";
"@babel/cli": "^7.1.2",
"@babel/core": "^7.0.0"
"emotion": "^9.2.8",
"emotion-theming": "^9.2.6",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-emotion": "^9.2.8",
"babel-plugin-emotion": "^9.2.11" //.babelrc
["emotion",{
"autoLabel": true,
"hoist": true,
"sourceMap": false,
"extractStatic": true,
"outputDir": "esm"
}
] |
What: #180
Why: Prevents polluting src tree when preparing production / static builds.
How: By saving the optional key
outputDir
in the babel plugin state and doing extra stuff if that key is present at the end of the babel transformationChecklist:
I used the code from pr #396 and just updated it to be complient with the latest version. I changed import style to absolute just to make sure that we can't go wrong here.