-
Notifications
You must be signed in to change notification settings - Fork 6
Add experimental support for symlinked modules #231
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| exports.dummy = { | ||
| some: "dummy value" | ||
| }; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI: We use underscores instead of hyphens in file and directory names. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { dummy } from "some-cjs-module"; | ||
|
|
||
| console.log(dummy); // eslint-disable-line no-console |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |||||
|
|
||||||
| let { MockAssetManager, makeBundle, FIXTURES_DIR } = require("./util"); | ||||||
| let faucetJS = require("../../lib").plugin; | ||||||
| const fs = require("fs"); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
for consistency 🙂 |
||||||
| let path = require("path"); | ||||||
| let assert = require("assert"); | ||||||
|
|
||||||
|
|
@@ -412,4 +413,49 @@ console.log(\`[DUMMY] $\{util}\`); // eslint-disable-line no-console | |||||
| assetManager.assertWriteCount(1); | ||||||
| }); | ||||||
| }); | ||||||
|
|
||||||
| describe("working with linked modules", () => { | ||||||
| // in case some set this env variable before | ||||||
| let initialFlagValue = process.env.FAUCET_EXPERIMENTAL_SYMLINKS; | ||||||
|
|
||||||
| beforeEach(() => { | ||||||
| fs.symlinkSync( | ||||||
| path.resolve(FIXTURES_DIR, "./external/cjs-module"), | ||||||
| path.resolve(FIXTURES_DIR, "./node_modules/some-cjs-module"), | ||||||
| "dir" | ||||||
| ); | ||||||
|
|
||||||
| process.env.FAUCET_EXPERIMENTAL_SYMLINKS = "true"; | ||||||
| }); | ||||||
|
|
||||||
| afterEach(() => { | ||||||
| fs.unlinkSync(path.resolve(FIXTURES_DIR, "./node_modules/some-cjs-module")); | ||||||
| process.env.FAUCET_EXPERIMENTAL_SYMLINKS = initialFlagValue; | ||||||
| }); | ||||||
|
|
||||||
| it("should preserve symlinks when env varialbe is set", () => { | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
typo 🙂 |
||||||
| let config = [{ | ||||||
| source: "./src/import-symlinked.js", | ||||||
| target: "./dist/bundle.js", | ||||||
| format: "CommonJS" | ||||||
| }]; | ||||||
| let assetManager = new MockAssetManager(FIXTURES_DIR); | ||||||
|
|
||||||
| return faucetJS(config, assetManager, DEFAULT_OPTIONS)(). | ||||||
| then(() => { | ||||||
| assetManager.assertWrites([{ | ||||||
| filepath: path.resolve(FIXTURES_DIR, "./dist/bundle.js"), | ||||||
| content: makeBundle(` | ||||||
| 'use strict'; | ||||||
|
|
||||||
| var dummy = { | ||||||
| some: "dummy value" | ||||||
| }; | ||||||
|
|
||||||
| console.log(dummy); // eslint-disable-line no-console | ||||||
| `) | ||||||
| }]); | ||||||
| }); | ||||||
| }); | ||||||
| }); | ||||||
| }); | ||||||
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.
This seems like a potentially significant change? I vaguely remember pondering this expression extensively (years ago though), so I'm hesitant to change it without asking: What's the significance in this particular context?
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.
Plus one on that