Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Ensure parse bypass is only done for files not loaded by ESM. [closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Jan 17, 2018
1 parent e9698d3 commit 0aa02eb
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"optimize-js-plugin": "0.0.4",
"pify": "^3.0.0",
"pm2": "^2.8.0",
"postcss": "^6.0.16",
"semver": "^5.5.0",
"sleep": "^5.1.1",
"trash": "^4.2.1",
Expand Down
1 change: 1 addition & 0 deletions src/hook/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ function hook(Mod, parent) {

if (moduleState.parsing) {
if (! entry.esm &&
! (entry.parent && entry.parent.esm) &&
(entry.data.package === defaultPkgInfo ||
(entry.parent && entry.parent.data.package === defaultPkgInfo))) {
entry.state = 3
Expand Down
5 changes: 5 additions & 0 deletions test/fixture/scenario/postcss/.esmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
cjs: true,
debug: true,
esm: "all"
}
8 changes: 8 additions & 0 deletions test/fixture/scenario/postcss/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"use strict"

const assert = require("assert")

require = require("../../../../")(module)
const fontFamilySystemUI = require("./main.mjs").default

assert.strictEqual(typeof fontFamilySystemUI, "function")
3 changes: 3 additions & 0 deletions test/fixture/scenario/postcss/main.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import postcss from "postcss"

export default postcss.plugin("postcss-font-family-system-ui", () => {})
8 changes: 8 additions & 0 deletions test/scenario-tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ describe("scenarios", function () {
return exec("nyc", nycArgs)
})

it("should work with postcss", () => {
const dirPath = path.resolve(testPath, "fixture/scenario/postcss")
const indexPath = path.resolve(dirPath, "index.js")

return Promise.resolve()
.then(() => exec(nodePath, [indexPath]))
})

;(canTestPM2 ? it : xit)(
"should work with pm2", () => {
const dirPath = path.resolve(testPath, "fixture/scenario/babel-register")
Expand Down

0 comments on commit 0aa02eb

Please sign in to comment.